Mobile Website Template and PWA
Thank you for purchasing Apptastic
In this documentation, we'll be covering absolutely every
aspect of our item, to help you achieve the perfect Mobile Website, PWA or Hybrid App. Our newest generation
of frameworks released/updated after October 2020 are powered by Bootstrap. Therefore, all Bootstrap components will be
fully compatible with our products, and also, our own custom built elements that will be super easy for you to use and understand.
Remember. If you get stuck, we're always here to help, but this documentation will most likely cover absolutely any question you may have.
We've written this documentation to suit both developer and less experienced users.
Our goal is to give you the best possible experience, so don't be afraid to ask if you get stuck along the road.
Our entire system is created with components, as the quantity of elements needed to create this by hard coding them is simply not the optimal solution. In order to perfectly understand our product, we strongly recommend you read the documentation in the following order.
By understanding the core structure and utility classes and then the components, you will be a master of our file incredibly fast!
Components will make creating new pages easy and incredibly fast, offering you an unprecedented level of flexibility when it comes to adding your own ideas into our product.
The _starter.html page explained, and the basic page structures.
The basic structure of our products is represented in the _starter.html. Here you can populate it with components or page elements, Bootstrap features as you need to, but, we need to make sure you understand it to avoid errors.
|
01
02
03
04
05
06
07
09
10
11
12
13
14
15
16
17
18
|
<!-- Preloader will be added here--><div id="page"> <!-- Header Bar will be added here --> <!-- Footer Bar will be added here --> <!-- Page Title will be added here --> <div class="page-content header-clear-VALUE"> <!-- Add your Canvas Elements - meanign - Components and Page Elements Here--> </div> <!-- Off Canvas Elements Here --></div> |
This is the main structure of our products. So following this structure is essential to the functioning of the products, especially since we use a lot of off-canvas elements to create a beautiful user experience.
The canvas is considered the place where you have all the elements you see on the page that don't move only when scrolling.
Everything you see inside the page-content class is considered an on-canvas element.
These elements are visible on the screen, at all times, and don't move except for when you are scrolling.
These elements are defined as elements that appear from the left, right, top or bottom of the screen, coming from outside the visible area of the screen.
These elements are placed outside the page-content, and this is very important, since they interact with the page-content. For example, menus can push the page-content and create a dark overlay.
For this reason, the following list of elements must always be placed outside the page-content
The body tag is used for controling the theme of the page and also the highlight and background color.
1 | <body class="theme-light" data-background="none" data-highlight="red2"> |
The class we use to determine the color theme of our product. Use theme-dark for dark mode, theme-light for light mode and detect-theme to automatically detect your devices
default theme settings. If this is not supported by your device, the page will automatically default to theme-light. Most modern devices now support automatic theme detection, and you can check this in component-auto-dark.html
Click to view Available Colors for data-background and data-highlight
Our header is designed to be super easy to use and highly flexible for your use case. With this being said, the header currently supports a few styles, which we'll explain below, and which can be seen and used inside component-headers.html found in the pack.
1 2 3 4 5 6 7 | <div class="header header-fixed header-logo-left"> <a href="index.html" class="header-title">Apptastic</a> <a href="#" class="header-icon header-icon-1"><i class="fas fa-envelope"></i><span class="badge bg-green1-dark">5</span></a> <a href="#" class="header-icon header-icon-2"><i class="fas fa-bars"></i></a> <a href="#" class="header-icon header-icon-3"><i class="fas fa-heart color-red2-light"></i></a> <a href="#" class="header-icon header-icon-4"><i class="fas fa-share-alt"></i></a></div> |
Let's explain the header line by line, showcasing what it can do at the same time.
Line 1 is the main wrapping class. This contains the class header, to define the element, header-fixed, which will make the header fixed at the top of the screen and also, a class
which is used to determine the style. You can use any of the following classes.
header-logo-left - Logo Left with 4 icons on the right side
header-logo-right - Logo Right with 4 icons on the left side
header-logo-center - Logo Center with 2 icons on left and 2 icons on right
header-logo-app - 1 icon on the left, logo and 3 icons on the right side.
Line 2 is the header logo. This can be an image or a text. You can select this as an image by setting the header-title class to header-logo.
The image can be found in the main css file by searching for "header-logo" using CTRL+F or CMD+F and replacing the image there with your own.
Lines 3,4,5,6 are the header icons. These are numbered using header-icon-1 to 4 and you can change their position based on this number.
The structure of the page is intended to be as simple as possible using the _starter-NAME.html pages included, you will find the above elements inside, and you can start placing your content inside the page-content class right away! Continue with the documentation to learn about the menus and color classes.
The most important feature, that will allow you to endlessly style Apptastic
Ultilty classes or, as they are known, secondary classes are re-usable pieces of CSS added to your HTML to ehnance and
extended certain features. For example, you may want to re-use a color, so instead of re-writting CSS for each time we want that color, we create a class for it.
These are the default Boostrap Classes available with the Boostrap framework - https://getbootstrap.com/docs/4.4/utilities
But, beside these classes, we wanted to give you even more flexibility, while keeping the naming convention typical to Bootstrap, so you don't have to learn any new fancy and complicated codes.
Here is a perfect example where utility classes come super handy.
1 | <h1 class="font-16 font-800 text-uppercase pt-3 mb-0">I'm a heading</h1> |
The above h1 has a few classes attached, each one has a different purpose. You can change font sizes, font weight, transform the text and even adjust paddings and margins. These are all utility classes and they are awesome! Let's dive into them.
If you are accustomed to Boostrap 4.4 Spacing, you can continue directly to this point
There are cases where you need to control the position of an element. A great example is cards where positioning is very important, but
in order not to create "rigid" coded cards, we use the Boostrap Spacing properties.
These properties allow you to control the margin and padding both left, right top and bottom of any given element on screen. Let's dive in:
You can combine the above elements to give your element spacing you require as follows
[target][placement]-[value]
So, for example, to create a margin bottom of 15 pixels you will use mb-3. This combination method applies to all the values above. You can also create negative values for margins, for example if you
want to pull an element under another element. Let's say you want a paragraph to go a bit higher under a heading, in that case, simply add n to your value (n = negative) and the
value there will become a negative value. For example mt-n2, will give the element a negative top margin of 10 pixels.
This is the standard method found and used in Boostrap's official documentation and offers immense flexibility to element positioning.
To align text, simply use the following classes. These are self-explanatory in their names
text-center
text-left
text-right
To transform text, simply use the following classes. These are self-explanatory in their names
text-uppercase
text-lowercase
text-capitalize
To create a rounded border using our template, you simply have to use the parameters xs, s, m, sm, l, xl attached at the end of the rounded- class, just like for Bootstrap. The
default Bootstrap classses are still working if you wish to use those as well.
rounded-0 - removes rounded corners from pre-existing rounded element
rounded-xs
rounded-s
rounded-m
rounded-l
rounded-xl
Adding different shadows to your elements such as buttons, boxes, images, cards and other elements is done in the same fashion. Simply use the shadow- and the parameters xs, s, sm, m, l, xl at the end
shadow-0 - removes shadow from pre-existing shadow element
shadow-xs
shadow-s
shadow-m
shadow-l
shadow-xl
Opacity is great for controling overlay of cards or for reducing the contrast for text. These are very useful to have throughout the item and will be very useful in Cards.
These values are increasing 10-20-30 etc, etc. The higher the number, the more visible it is, the lower the number the more invisible it is.
opacity-00
opacity-10
opacity-20
....
opacity-80
opacity-90
The font weight system available in bootstrap made it hard for users to easily determine the weight of a font that has for example 9 styles.
Our system works on the simple contept that you place the font- followed by the weight of the font you wish to use. Lower is thiner, higher is bolder.
font-200
font-300
font-400
font-500
font-600
font-700
font-800
font-900
We created these classes to increase the flexibility of your typography size. Sometimes, the included sizes are just not enough, and adding style="font-size:12px" is a hack
and we like to keep our code professional and clean. To avoid this, we created an array of font sizes, from 8 pixels up to 40 pixels. To use them, simply add the font- followed by the font size you wish to use
font-8
font-9
font-10
..........
font-40
You may have noticed throughout our code that we use bg-NUMBER for backgrounds. These are demo backgrounds that can be found in the zDemo.scss file or inside style.css/bootstrap.css.
These are re-usable background images we use for cards. You can replace these images by searching for them in the CSS and replacing the images with your own
bg-1 to bg-30
We also have some aditional utilities you can use, that we really can't add in any of the above elements. These utilties are either classes or, in case you see data- in front of them, they are attributes.
data-toggle-theme-switch - changes from dark to light or light to dark
border-0 - removes the border from an element, for example, great on List Groups on the last element.
The idea of creating something flexible was always in our mind, and from our customer feedback it was easy to understand that most users who just want a fast setup for their PWA don't know and don't want to use CSS. This gives users the option of having a copy paste design with as minimal use of CSS. Everything can be created using classes while writing your HTML, and everything in our product can be enhanced with these elements.
The power and ease of colors
Our color system works on CSS and SCSS, so whichever you are comfortable with you can easily use. You can find the colors inside the styles/highlights folders or inside the scss/highlights.
Using SCSS, simply open the scss/highlights/_colors.scss and replace the $defaultGradient, $colorHighlightLight and $colorHighlightDark with your colors. These will automatically apply to all elements that use gradient-highlight bg-highlight and color-highlight classes, plus the footer menu active state and sidebar menu active state. The $defaultGradient colors are the composed by the colorHighlightLight and colorHighlightDark.
Every color above can be combined and used following way.
For Background Gradient
gradient-awesomeBuyer
For Text Color
awesomeBuyer-light
awesomeBuyer-dark
For Backgrounds
bg-awesomeBuyer-light
bg-awesomeBuyer-dark
For Borders
border-awesomeBuyer-light
border-awesomeBuyer-dark
For Highlights
bg-highlight
color-highlight
gradient-highlight
border-highlight
Yes, and you can add more with great ease. You will find just under the colorArray in custom.js the socialColorArray, which includes just one brand name and a color. This will generate color-BrandName and bg-BrandName. Add more simply by duplicating the code. You can add more in the highlights/_colors.scss file.
Open the scss/highlight/_colors.scss and simply duplicate any line from the $colorPack list, adding your hex colors there. These will automatically be generated by the SCSS and you'll be able to combine them using the above explanation.
To create highlight files, simply duplicate the _highlight-COLOR.scss or the highlight-color.css file, and change your colors with the ones you require. Once you've done this, you can
trigger Apptastic to apply the color, and rember it by adding the following data-highlight-style="styles/highlights/highlight-YourNewFile.css" to any button
you want. Once you click it, Apptastic will load the style you just created and add it to the localstorage memory. When you visit again, Apptastic will add that color to your page.
The body tag is used for controling the theme of the page and also the highlight and background color.
1 | <body class="theme-light" data-background="none" data-highlight="red2"> |
The class we use to determine the color theme of our product. Use theme-dark for dark mode, theme-light for light mode and detect-theme to automatically detect your devices
default theme settings. If this is not supported by your device, the page will automatically default to theme-light. Most modern devices now support automatic theme detection, and you can check this in component-auto-dark.html
To change the body background, simply replace "none" in the body tag with any of the colors in the list above.
To change the color of color-highlight / bg-highlight simply replace "red2" with any of the colors from the list above.
Let's say you have a black card where you have a white text. When you go to dark mode, that text will become black and no longer readable. This is where
the class color-theme is great. The color-theme and bg-theme are always the opposite color of the theme you have selected.
theme-dark - color-theme will be dark and bg-theme will be white
theme-light - color-theme will be light and bg-theme will be black
Action Sheets, Modals, Sidebars.
These menu systems are custom built to include effects and more beautiful interfaces than the default ones included by Bootstrap. They are incredibly well optimized to use full CSS3 and will work flawelessly even on low-end budget devices.
Individual Examples included after this section
First of all, let's take a simple structure, without any menu settings attached. This is the starter of the menu. For simpler to read and follow we made each attribute in the below example on a separate line so we can explain them by number.1 2 3 4 5 6 7 | <div id="MENU_UNIQUE_NAME"class="menu MENU_STYLES MENU_BOX_POSITION"data-menu-height="VALUE_IN_PX"data-menu-width="VALUE_IN_PX"data-menu-effect="MENU_EFFECT"><!-- Place your menu, action sheet, action modal stuff here --></div> |
MENU_STYLES - utility classes such as rounded-VALUE or shadow-VALUE to change the shape of the menu. You can even make the menu detach from the sides of the screen, meaning, feel like floating by adding menu-box-detached utility class here.
MENU_BOX_POSITION - to control the placement of the menu
menu-box-left - to create a sidebar left
menu-box-left - to create a sidebar right
menu-box-bottom - to create a bottom menu / action sheet
menu-box-top - to create a top menu / action sheet
menu-box-modal - to create a modal window
MENU_EFFECT - supports any of the following menu effects
menu-push - will push the page-content with the height or width of the menu you selected
menu-parallax - will push the page-content 1/10 of the size of the menu, creating a parallax type effect
deleting line 5 - will come above your page-content
1 2 3 4 | //show menu$('#MENU_UNIQUE_NAME').showMenu();//hide menu$('#MENU_UNIQUE_NAME').hideMenu(); |
Yes! Inside your menu, add a button with the data-menu="your-menu-id" and that menu will be triggered.
Add the class close-menu to any button inside your menu. This will trigger it to close.
Used in Action Sheets, Share Menus, anything that comes from the bottom.
1 2 3 4 5 6 | <div id="MENU_UNIQUE_NAME" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="300" data-menu-effect="menu-parallax"> <!-- your menu stuff here--></div> |
Used in Action Sheets, Share Menus, anything that comes from the top.
1 2 3 4 5 6 | <div id="MENU_UNIQUE_NAME" class="menu menu-box-top menu-box-detached rounded-m" data-menu-height="300" data-menu-effect="menu-parallax"> <!-- your menu stuff here--></div> |
Used in Sidebar Navigations or Instant Articles.
1 2 3 4 5 6 | <div id="MENU_UNIQUE_NAME" class="menu menu-box-left" data-menu-width="300" data-menu-effect="menu-parallax"> <!-- your menu stuff here--></div> |
Used in Sidebar Navigations or Instant Articles.
1 2 3 4 5 6 | <div id="MENU_UNIQUE_NAME" class="menu menu-box-right" data-menu-width="300" data-menu-effect="menu-parallax"> <!-- your menu stuff here--></div> |
Can I still use Bootstrap default menus?
You can still use the Bootstrap system of menus, they will work and can be programatically triggered and activated just like expressed in bootstrap, but please keep the following things in mind
Apptastic uses a bottom menu designed to match the page styles, and is also loaded externally, making adding new pages, and editing old ones easy. Imagine your site has 50 pages, and you'd have to edit 50 pages to change a menu. That's why Apptastic loads the menu from outside to make your life easier when editing it.
The menu is composed of a top card, where the close icon is, the menu list itself, which is a list-group and the bottom area, which again is a list group.
<a id="nav-welcome" href="index.html"> <i class="fa fa-heart gradient-red color-white"></i> <span>Welcome</span> <i class="fa fa-angle-right"></i></a> <a id="nav-components" href="index-components.html"> <i class="fa fa-cog gradient-blue color-white"></i> <span>Components</span> <i class="fa fa-angle-right"></i></a> |
This is a menu item, simply duplicate it to create more. In your HTML file, you can activate this menu by adding the id to the data-menu-activate
<div id="menu-main" class="menu menu-box-left" data-menu-load="menu-main.html" data-menu-width="280" data-menu-active="nav-welcome"></div> |
Using our Products as Progressive Web Apps
A progressive web app basically means you can "Install" the website to your home screen, have an icon and make it look exactly like it's a native application. However, these come with some things that you MUST know.
In order for your website to trigger as a PWA, meaning, show the prompt to install it to your home screen, your page must meet the following criteria.
Android devices have a much better integration for PWA's making them easier to maintain and use. In the case of Android the
content is automatically refreshed whenever you open the PWA, always serving you fresh content.
In the case of iOS, Apple is holding strong to giving PWA's the true power they deserve. Apple only started reading manifest files and
accepting service workers with iOS 12, and even then, with small issues. In the case of iOS, the device will hard cache a copy on itself.
This causes the problem of your PWA showing old content, but we managed to get over that with a very simple script that will force your iOS device
to clear it's cache.
Mobile devices automatically update the PWA content when you visit or within a few hours after you've closed the App. This is based on an internal storage that we can't control. Therefore, we can force the app to always keep the content up to date, to avoid such issues. Simply open custom.js and at the very top, set the pwaNoCache to true. This will always clear all storages to keep the content fresh.
To disable the PWa simply set the pwaEnabled at the top of custom.js to false. This will disable the service worker completely.
1 2 3 | "display" : "fullscreen", |
1 2 3 4 5 | //Loading the Service Workerif ('serviceWorker' in navigator) { window.addEventListener('load', function() { navigator.serviceWorker.register('/yourfolder/_service-worker.js', {scope: '/yourfolder/'}); }); |
A tone of flexible components and pages await.
The components and pages available are so large we have a special page dedicated to them.
Components Documentation
Pages Documentation
Here are the most comon questions we get regarding our product.
At the very top of custom.js we set universal parameters to easily change major settings in the item. These are
isAJAX enables or disables the AJAX transition system we use in our product. If you want to connect our product to ReactJS or or a back end system where
your pages are pre-generated(php for example, laravel, wp) then set this to false.
isDevMode enables or disables a permanently fixed button on the screen, which you can easily use to tap and refresh the page. This is very useful, when you're in PWA mode
and adding new content and don't want to remove and re-add the app to the homescreen. Set this to true when you're editing your product, and when you're ready to go in production mode (deploy to customers)
set it to false.
pwaEnabled - activates or disables the service worker which will allow the page to install on the home screen, set to false if you don't want to use as a PWA
pwaNoCache - if set to true, this will always serve fresh content when you open the app in pwa mode. Otherwise, you can view a cached version for a few hours before the service
worker triggeres a cache / storage clear itself
pwaRemind - once the user rejects the install ( clicks maybe later ) a local storage will be created and, after that time passes the prompt will appear again. The number in this
property represnets days until the prompt will appear again. If you set it to 0 it will appear everytime the user visits your page. We recommend a minimum of 1 day so it doesn't feel like a
spam banner.
We describe the functionallity of the AJAX page changer in this question. But, to make things short, the page will attempt to load the external link inside the div id page, causing the page to reload. In order to avoid this, simply add the class default-link to any link you aim towards an external page.
Firstly, if you're an absolute beginner in SCSS, don't be afraid. It's more like a CSS with re-usable variables, in the short way. You can read a small tutorial here
If you're already accustomed to SCSS, When editing our page, you can either edit the style.css element, by using CTRL+F or CMD+F to find the class you are looking for, or by using SCSS.
We structured the SCSS to keep Bootstrap's SCSS files in there and intact, in case you want to dive deep into customizing, and also included our own elements inside.
This is the structure of the SCSS folder
../bootstrap/
../components/
../pages/
../plugins/
../Apptastic/
../_bootstrap.scss
../style.scss
Let's explain.
../bootstrap/ - contains the default Bootstrap SCSS system, unalatered. You can go to /bootstrap/bootstrap.scss to remove elements you don't need or follow
the Bootstrap SCSS logic to edit this file
../components/ - contains all our custom built adition to the component system already presented by bootstrap
../pages/ - contains all our custom built pages
../Apptastic/ - contains all elements that Apptastic depends on to run effectively, including the dark mode, header, footer, menu, logos but also the structure and utility classes. This will also contain the variables we used for fonts, borders, shadows and the dark mode color
Even though on paper your Mobie Device has the power of a laptop, they all use Mobile Modems and these are very poor in loading performance if pages are not properly optimized.
Having multiple CSS files will allow you to organize and group your JS/CSS files properly in development. However, this also means that there are multiple HTTP requests to make. HTTP requests are more expensive in terms of loading time as it has to contact the server and fetch the file.
In any modern code editor ( we recommend http://brackets.io, it's fast, free and has Live Preview mode) you can use CTRL+F on Windows or CMD+F on Mac to search for
any class name you want in style.css
Remember, this is a Mobile product, and although you or I can have iPhone XXXXSSS and Galaxy Note Infinity, there are devices out there with less powerful modems. We want to keep the calls to a minimum
to ensure the fastest loading time possible.
Open the style.css and use CTRL+F or CMD+F to edit find header-logo, or footer-logo. You can find the class names that you wish to search for by right clicking in Google Chrome and clicking "Inspect Element". In the inspection window you will see the class name and on what line it can be found in style.css
When creating our previous framework, we used a very small and fast loading system that didn't necessarily require AJAX to work, but when working with Bootstrap, performance
for mobile devices is an issue. The structure is designed like this for 2 reasons.
1. To enable our AJAX page transition system to change the content of a div, not the body which would cause errors on Mobiles
2. To allow for effects when opening action sheets and action modals, a thing that is not offered in Bootstrap.
For most users, the structure is simple to follow. Think of the div id page as the body. Everything goes inside it. Think of the page-content as the place where only
the content that is on screen will go. It's the simplest possible alteration we can think of that won't requrie you to learn complex code structures.
The AJAX system is here to make pages load much faster and smoother.
Yes, absolutely you can! Just be sure that if you use Modals, Toasts, Snackbars you place these outside your div class="page-content" and make sure your call codes for these are inserted inside custom.js inside the init_template() function. You can read more about this in the How do I add my own JavaScript Code section.
The AJAX system we use is for page transitions and also for massively optimizing page speed. This works on a very simple concept.
When you first access the site, for example, you land on index.html. Our AJAX system will automatically "remember" (not cache) the styles and scripts
sections of your page. When you click a button to go to awesomeBuyer.html for example, the code will only replace the content found inside the div id="page".
Once the awesomeBuyer.html page is injected inside the div id="page" the init_template() function from custom.js will be destroyed and re-fired. This assures maximum
performance while making sure all your JavaScript still runs perfectly.
This means, there are no calls made to the JS or Style files, and they are still used as the ones originally loaded when you entered the site. For certain devices
that make calls on each page such as Androids and most of the times iOS, this increases the speed of the page dramatically.
To run any script and style on all pages, especially when using AJAX there is a correct way of doing it.
This is essential so the page will be able to access the script if you come from it directly or from a different page, and the init_template() function fires / is triggered when you are landing on a new page.
The above chapter section shows exactly how you should place your JavaScript code for it to run perfectly.
If you disable AJAX page transitions your page will feel a bit slower, basically loading just like anyother HTML, CSS and JS site running Bootstrap.
However, this may be necessary if you are coding for WordPress, Laravel, Droopal, Joomla or any other CMS where you must pre-build pages.
To disable AJAX
all you have to do is open custom.js and set: isAJAX = false - at the very top of custom.js
All you have to do is open custom.js and set: isPWA = false - at the very top of custom.js
Our page will remember the settings you have for the color highlight and the background color if you set them from the bottom menu, and even for the dark mode or light mode. This is automatically done with Cookies based on the color highlight or background you've selected from the page. To remove these cookies simply clear the cookies from the page. If your page doesn't use the menus for changing the colors and backgrounds, cookies won't be created.
Our menus can be triggered programatically just like other Bootstrap elements with a simple function. In custom.js, inside the init_template() function after line 88 trigger menus by using the following codes
1 2 3 4 | //show menu$('#MENU_UNIQUE_NAME').showMenu();//hide menu$('#MENU_UNIQUE_NAME').hideMenu(); |
Follow the documentation from Bootstraps's 4.4 Official Website to trigger the menu you need. All our components except for the custom menus follow the official Bootstrap programatic logic.
For most elements, we already added the required parameters to make sure things don't get under the notch, but let's say you want to create a cover page or a page without a header and you notice this goes under the notch. Simply place the class notch-clear on the element that is under the notch. So if you have a cover page that contains an icon that shows under the notch, don't add notch-clear on the coverpage, add it to the icon.
We'll gladly analyze your page and give you the exact tips and changes you need to make to get the most out of your page. Here is a short list of things you should implement in your page.
If you've done this and it's still not as fast as it should be, feel free to contact us, and we'll gladly assist you, analyze your page and give you all the tips you need to achieve the best performance possible.
Don't worry if you can't figure something out. We are always here to help.
In case you have any issues that are not mentioned here, please send us a ticket via our Support Forum. We
are always here to help and, unless we're sleeping, we answer all your questions in under 2 hours.