• Stars
    star
    158
  • Rank 229,793 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ“ฒ A useful modern JavaScript solution that helps your website users to add (install) a progressive web application (PWA) to the Home Screen of their mobile iOS devices.

๐Ÿ“ฒ a2hs.js

Add progressive web application (PWA) to Home Screen on iOS

iPhone X mockup a2hs.js

npm version bundle size code style: prettier license twit link

A useful modern JavaScript solution that helps your website users to add (install) a progressive web application (PWA) to the Home Screen of their mobile iOS devices. Designed for the latest 4 major versions of iOS Safari.

The Why?

As you probably know, iOS Safari doesn't have a built-in pop-up window with a suggestion to install a progressive web app on an iPhone/iPad (like Google Chrome). The a2hs.js project easily solves this problem!

Also, it's lightweight, production-ready, zero-configuration, has no dependencies and perfectly works with all of popular JavaScript frontend frameworks.

Install

npm install --save a2hs.js

Usage

/**
 * Import a2hs.js
 */
import AddToHomeScreen from "a2hs.js";

/**
 * Simple (with default config) init
 */
AddToHomeScreen();

/**
 * Advanced (with your config) init
 */
AddToHomeScreen({
  brandName: "Demo",
  fontFamily: "Tahoma, sans-serif",
  backgroundColor: "red",
  color: "white",
  // ... see full list of config options below
});

Config

config example

~ Description Default
backgroundColor Background color for container #f9f9f9
padding Padding for container 10px
shadowColor Shadow color for top of container #e9e9e9
shadowSize Shadow size for top of container 10px
fontFamily Font family for content in container -apple-system, sans-serif
color Font color for content in container #5d5d5d
fontSize Font size for content in container 0.9rem
brandName Brand for default htmlContent ""
logoImage Logo for container inline SVG
htmlContent Content for container with HTML Install <strong>{{brandName}} web app</strong> on your iOS device: tap share and <strong>Add to Home Screen</strong> โ†“

Demo

demo

PWA logo

The content container, by default, attached to bottom of iOS device screen (used CSS property position: fixed). The container will not be displayed:

  • If user opened website, as a progressive web app (PWA);
  • If user clicked once on content container (used localStorage for save state);

Demo on localhost

git clone https://github.com/koddr/a2hs.js.git
cd a2hs.js

npm install
npm start

  Server running at http://localhost:1234 
  โœจ  Built in 18ms.

๐Ÿ–ฅ Desktop Google Chrome:

  1. Then, go to Developer Tools on opened page http://localhost:1234;
  2. Switch to Device toolbar and choose iPhone in Emulated Devices select;
  3. โ†บ Refresh page;

Live demo

Go to private mode on your iOS Safari and open True web artisans website.

Animation

/**
 * Add slide animation when loading a2hs.js container:
 * slideUp, slideDown, slideLeft, slideRight
 *
 * Params: 
 *  animation speed (example: 0.7s)
 */

.a2hs__container {
  animation: slideUp 0.7s ease;
}

@keyframes slideUp {
  0% {
    opacity: 0;
    transform: translateY(240px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  0% {
    opacity: 0;
    transform: translateY(-240px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideLeft {
  0% {
    opacity: 0;
    transform: translateX(240px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideRight {
  0% {
    opacity: 0;
    transform: translateX(-240px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

Size limit report

npm run size

  โœจ Built in 234ms.

  dist/index.js.map    5.68 KB     5ms
  dist/index.js        3.72 KB    13ms

  Time limit:   50 ms
  Package size: 1.29 KB with all dependencies, minified and gzipped
  Loading time: 26 ms   on slow 3G
  Running time: 21 ms   on Snapdragon 410
  Total time:   47 ms

Thanks to Andrey Sitnik @ai/size-limit.

Developers

Project assistance

If you want to say ยซthank youยป or/and support active development a2hs.js:

  1. Add a GitHub Star to project.
  2. Twit about project on your Twitter.
  3. Donate some money to project author via PayPal: @paypal.me/koddr.
  4. Join DigitalOcean at our referral link (your profit is $100 and we get $25).

Thanks for your support! ๐Ÿ˜˜ Together, we make this project better every day.

DigitalOcean Referral Badge

License

MIT

More Repositories

1

goodshare.js

๐Ÿš€ ะ useful modern JavaScript solution for share a link from your website to social networks or mobile messengers. Easy to install and configuring on any of your website!
JavaScript
487
star
2

vue-goodshare

๐Ÿฟ Vue.js component for social share. A simple way to share a link on the pages of your website in the most popular (and not so) social networks. Powered by goodshare.js project.
Vue
447
star
3

tutorial-go-fiber-rest-api

๐Ÿ“– Build a RESTful API on Go: Fiber, PostgreSQL, JWT and Swagger docs in isolated Docker containers.
Go
264
star
4

bottle-vue-kickstart

๐Ÿ• Very basic Bottle kickstart kit with Vue.js and Webpack. Included Axios, Autoprefixer, Babel, Webpack config, demo app with Bulma and Web font loader.
HTML
91
star
5

yandex-music-desktop

๐ŸŽต Yandex.Music Desktop (un-official port of website). Please note: this is only webview port of Yandex.Music website as desktop app for macOS, Windows 10 and GNU/Linux!
C
84
star
6

useful-playbooks

๐Ÿšš Useful Ansible playbooks for easily deploy your website or webapp to absolutely fresh remote virtual server and automation many processes. Only 3 minutes from the playbook run to complete setup server and start it.
73
star
7

example-embed-static-files-go

The easiest way to embed static files into a binary file in your Golang app (no external dependencies).
Go
46
star
8

tutorial-go-fiber-rabbitmq

๐Ÿ“– Tutorial: Working with RabbitMQ in Golang by examples.
Go
37
star
9

sweetconfirm.js

๐Ÿ‘ŒA useful zero-dependencies, less than 434 Bytes (gzipped), pure JavaScript & CSS solution for drop an annoying pop-ups confirming the submission of form in your web apps.
JavaScript
36
star
10

just-scroll

Simple indicate the possibility of scrolling on a page with ะกSS3 animation.
Sass
34
star
11

example-static-website-docker-nginx-certbot

Example static website with Docker, Nginx and Certbot
Shell
32
star
12

example-go-react-macos-app-1

Example native macOS app on Go (Golang) and React.js
JavaScript
30
star
13

tutorial-go-asynq

๐Ÿ“– Tutorial: Asynq. Simple, reliable & efficient distributed task queue for your next Go project.
Go
24
star
14

drupal_8_unset_html_head_link

๐Ÿค– Module for unset any wrong HTML links (like rel="delete-form", rel="edit-form", etc.) from head on Drupal 8.x websites. This is trust way to grow up position in SERP Google, Yandex, etc.
18
star
15

example-go-config-yaml

Example Go web app with YAML config.
Go
18
star
16

example-go-grpc-server

Example gRPC server on Go
Go
14
star
17

actions-sapper

:octocat: GitHub Action for generating a static website with Sapper.
Shell
11
star
18

vsac

โœ… ะutomation of routine tasks on a new server for humans. Only verified configs and best practices. Just git clone and run it!
Shell
10
star
19

shrts.website

๐Ÿ”— A links shortener project for websites & useful snippets for internal (and not really) needs. Each URL in the list below is checked and leads to the corresponding original link using a 301 (Moved Permanently) redirect.
10
star
20

yandex-radio-desktop

๐Ÿ“ป Yandex.Radio Desktop (un-official port of website). Please note: this is only webview port of Yandex.Radio website as desktop app for macOS and Windows 10 (GNU/Linux coming soon)!
Makefile
8
star
21

tutorial-go-i18n

๐Ÿ“– Tutorial: An easy way to translate your Golang application
Go
7
star
22

json2csv

๐Ÿšด The parser can read given folder with JSON files, filtering and qualifying input data with intent & stop words dictionaries and save results to CSV files by given chunk size.
Go
7
star
23

example-github-actions

Automate that! ๐Ÿ‘Š A practical guide to GitHub Actions: build & deploy a static 11ty website to remote virtual server after push.
JavaScript
7
star
24

quart-logo

๐Ÿ–ผ Official Quart logo (with style guide).
6
star
25

gosl

๐Ÿ“š The Go Snippet Library provides snippets collection for working with routine operations in your Go programs with a super user-friendly API and the most efficient performance.
Go
6
star
26

go-email-sender

๐Ÿ“ฎ Simple (but useful) email sender written in pure Go v1.17. Support HTML templates and attachments.
Go
6
star
27

reactless-ts

โœจ A handy production-ready template for rapidly frontend development that you've often dreamed of. Small, but with full backward compatibility to all of React.js ecosystem, but without its overhead!
TypeScript
6
star
28

do-spaces-microservice

๐Ÿงบ Microservice for upload, remove and list objects to/from your DigitalOcean Spaces. Production-ready, zero configuration, working out of the box!
Go
4
star
29

github-backup-automation

โœŠ A Docker container to backup automation for your GitHub accounts (repositories, gists, organizations).
Shell
4
star
30

csv2api

๐Ÿ„โ€โ™‚๏ธ The parser reads the CSV file with the raw data, filters the records, identifies fields to be changed, and sends a request to update the data to the specified endpoint of your REST API.
Go
3
star
31

wotchy

Watch & Listen YouTube videos on your terminal, but without Ads and other non-freedom things.
Go
3
star
32

yatr

๐Ÿƒ Yet Another Task Runner (or yatr for a short) allows you to organize and automate your routine operations that you normally do in Makefile (or else) for each project.
Go
3
star
33

template-go

The template repository for my next Go project.
Go
3
star
34

storeon-sessionstorage

Module for storeon to persist data from state to session storage
JavaScript
3
star
35

starlette-logo

๐Ÿ–ผ Official Starlette logo (with style guide).
2
star
36

koddr

My personal page on GitHub.
2
star
37

utilities-komentory

Useful Golang utilities for Authenticate and API servers for the Komentory project. Just for reference and nostalgia :)
Go
2
star
38

asynq-logo

๐Ÿ–ผ Official Asynq & Asynqmon logos (with style guide).
2
star
39

app-komentory

Frontend SPA application on Vue 3.x (TypeScript) for the Komentory project. Just for reference and nostalgia :)
Vue
1
star
40

dotfiles

My environment dotfiles, configs & bash scripts.
Nix
1
star
41

auth-komentory

Authentication server on Golang (Fiber) for the Komentory project. Just for reference and nostalgia :)
Go
1
star
42

go-errorify

๐Ÿ’Ž The understandable zero-dependencies multilingual error wrapper for your Go (Golang) apps or CLI.
Go
1
star
43

go-lb

๐Ÿšฆ The simplest load balancer ever written in Golang.
Go
1
star
44

api-komentory

API server on Golang (Fiber) for the Komentory project. Just for reference and nostalgia :)
Go
1
star
45

easily-csv-import

Easily CSV splitter with Pandas
Python
1
star
46

actions-sapper-demo

๐Ÿ‘€ Demo for Sapper Action.
JavaScript
1
star