Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumebriday committed Dec 6, 2020
0 parents commit 4ac5e48
Show file tree
Hide file tree
Showing 19 changed files with 6,607 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://eslint.org/docs/user-guide/configuring

module.exports = {
env: {
browser: true,
node: true,
es6: true
}
}
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patreon: guillaumebriday
15 changes: 15 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lint

on: [push]

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '14.x'
- run: |
yarn install
yarn lint
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
pkg
build
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.13.0
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.github
jest
.babelrc
jest.config.js
index.html
snowpack.config.json
netlify.toml
.node-version
.eslintrc.js
src
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 120
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.0.0] - 2020-12-06

### Added

- Adding controller
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Guillaume Briday

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Stimulus Prefetch

[![](https://img.shields.io/npm/dt/stimulus-prefetch.svg)](https://www.npmjs.com/package/stimulus-prefetch)
[![](https://img.shields.io/npm/v/stimulus-prefetch.svg)](https://www.npmjs.com/package/stimulus-prefetch)
[![](https://github.com/stimulus-components/stimulus-prefetch/workflows/Lint/badge.svg)](https://github.com/stimulus-components/stimulus-prefetch)
[![](https://img.shields.io/github/license/stimulus-components/stimulus-prefetch.svg)](https://github.com/stimulus-components/stimulus-prefetch)
[![Netlify Status](https://api.netlify.com/api/v1/badges/d62d950e-aae7-464d-8333-1078a16ec481/deploy-status)](https://stimulus-prefetch.netlify.com)

## Getting started

A Stimulus controller that prefetch in-viewport links.

## 📚 Documentation

See [stimulus-prefetch documentation](https://stimulus-components.netlify.app/docs/components/stimulus-prefetch/).

## 👷‍♂️ Contributing

Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.

## 📝 License

This project is released under the [MIT](http://opensource.org/licenses/MIT) license.
191 changes: 191 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="description" content="A Stimulus controller that prefetch in-viewport links." />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://unpkg.com/tailwindcss@^2.0/dist/tailwind.min.css" rel="stylesheet" />

<title>Stimulus Prefetch</title>

<script type="module" defer>
import { Application } from 'stimulus'
import Prefetch from './src/index.js'

const application = Application.start()
application.register('prefetch', Prefetch)
</script>
</head>

<body>
<!-- This example requires Tailwind CSS v2.0+ -->
<div class="relative bg-gray-50 overflow-hidden">
<div class="hidden sm:block sm:absolute sm:inset-y-0 sm:h-full sm:w-full" aria-hidden="true">
<div class="relative h-full max-w-7xl mx-auto">
<svg
class="absolute right-full transform translate-y-1/4 translate-x-1/4 lg:translate-x-1/2"
width="404"
height="784"
fill="none"
viewBox="0 0 404 784"
>
<defs>
<pattern
id="f210dbf6-a58d-4871-961e-36d5016a0f49"
x="0"
y="0"
width="20"
height="20"
patternUnits="userSpaceOnUse"
>
<rect x="0" y="0" width="4" height="4" class="text-gray-200" fill="currentColor" />
</pattern>
</defs>
<rect width="404" height="784" fill="url(#f210dbf6-a58d-4871-961e-36d5016a0f49)" />
</svg>
<svg
class="absolute left-full transform -translate-y-3/4 -translate-x-1/4 md:-translate-y-1/2 lg:-translate-x-1/2"
width="404"
height="784"
fill="none"
viewBox="0 0 404 784"
>
<defs>
<pattern
id="5d0dd344-b041-4d26-bec4-8d33ea57ec9b"
x="0"
y="0"
width="20"
height="20"
patternUnits="userSpaceOnUse"
>
<rect x="0" y="0" width="4" height="4" class="text-gray-200" fill="currentColor" />
</pattern>
</defs>
<rect width="404" height="784" fill="url(#5d0dd344-b041-4d26-bec4-8d33ea57ec9b)" />
</svg>
</div>
</div>

<div class="relative pt-6 pb-16 sm:pb-24">
<main class="mt-16 mx-auto max-w-7xl px-4 sm:mt-24">
<div class="text-center">
<h1 class="text-4xl tracking-tight font-extrabold text-gray-900 sm:text-5xl md:text-6xl">
<span class="block xl:inline">Stimulus</span>
<span class="block text-yellow-600 xl:inline">Prefetch</span>
</h1>

<p class="mt-3 max-w-md mx-auto text-base text-gray-500 sm:text-lg md:mt-5 md:text-xl md:max-w-3xl">
A Stimulus controller that prefetch in-viewport links.
</p>

<p class="text-center mt-3">
<img class="inline-block" src="https://img.shields.io/npm/dt/stimulus-prefetch.svg" />
<img class="inline-block" src="https://img.shields.io/npm/v/stimulus-prefetch.svg" />

<img
class="inline-block"
src="https://github.com/stimulus-components/stimulus-prefetch/workflows/Lint/badge.svg"
/>

<img
class="inline-block"
src="https://img.shields.io/github/license/stimulus-components/stimulus-prefetch.svg"
/>

<img
class="inline-block"
src="https://api.netlify.com/api/v1/badges/d62d950e-aae7-464d-8333-1078a16ec481/deploy-status"
/>
</p>

<div class="mt-5 max-w-md mx-auto sm:flex sm:justify-center md:mt-8">
<div class="rounded-md shadow">
<a
href="https://github.com/stimulus-components/stimulus-prefetch"
class="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-white bg-yellow-600 hover:bg-yellow-700 md:py-4 md:text-lg md:px-10"
>
GitHub
</a>
</div>
<div class="mt-3 rounded-md shadow sm:mt-0 sm:ml-3">
<a
href="https://stimulus-components.netlify.app/docs/components/stimulus-prefetch/"
class="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-yellow-600 bg-white hover:bg-gray-50 md:py-4 md:text-lg md:px-10"
>
Documentation
</a>
</div>
</div>
</div>
</main>
</div>
</div>

<div class="relative h-full max-w-5xl mx-auto px-4">
<section class="mt-16">
<h2 class="text-2xl mt-4">Home</h2>
<p class="mt-3 text-gray-500 text-md">Scroll to prefetch the second page.</p>

<div style="height: 75vh;"></div>

<a href="/page.html" data-controller="prefetch" class="text-blue-500 hover:underline">Go to second page 👉</a>
</section>
</div>

<!-- This example requires Tailwind CSS v2.0+ -->
<footer class="bg-white">
<div class="max-w-7xl mx-auto py-12 px-4 overflow-hidden sm:px-6 lg:px-8">
<div class="-mx-5 -my-2 flex flex-wrap justify-center" aria-label="Footer">
<div class="px-5 py-2">
<p class="text-base text-gray-500">
stimulus-prefetch is a package from the
<a href="https://github.com/stimulus-components/stimulus-components" class="hover:text-gray-900 underline"
>stimulus-components</a
>
project.
</p>
</div>
</div>

<div class="mt-8 flex justify-center space-x-6">
<a
href="https://twitter.com/guillaumebriday"
target="_blank"
rel="noopener"
class="text-gray-400 hover:text-gray-500"
>
<span class="sr-only">Twitter</span>
<svg class="h-6 w-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path
d="M8.29 20.251c7.547 0 11.675-6.253 11.675-11.675 0-.178 0-.355-.012-.53A8.348 8.348 0 0022 5.92a8.19 8.19 0 01-2.357.646 4.118 4.118 0 001.804-2.27 8.224 8.224 0 01-2.605.996 4.107 4.107 0 00-6.993 3.743 11.65 11.65 0 01-8.457-4.287 4.106 4.106 0 001.27 5.477A4.072 4.072 0 012.8 9.713v.052a4.105 4.105 0 003.292 4.022 4.095 4.095 0 01-1.853.07 4.108 4.108 0 003.834 2.85A8.233 8.233 0 012 18.407a11.616 11.616 0 006.29 1.84"
/>
</svg>
</a>

<a
href="https://github.com/stimulus-components/stimulus-prefetch"
target="_blank"
rel="noopener"
class="text-gray-400 hover:text-gray-500"
>
<span class="sr-only">GitHub</span>
<svg class="h-6 w-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path
fill-rule="evenodd"
d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"
clip-rule="evenodd"
/>
</svg>
</a>
</div>

<p class="mt-8 text-center text-base text-gray-400">
This project is released under the
<a href="https://opensource.org/licenses/MIT" class="hover:text-gray-900 underline">MIT</a>
license.
</p>
</div>
</footer>
</body>
</html>
3 changes: 3 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
publish="build"
command="yarn prod"
60 changes: 60 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "stimulus-prefetch",
"version": "0.1.0",
"description": "A Stimulus controller that prefetch in-viewport links.",
"keywords": [
"stimulus",
"stimulusjs",
"stimulus controller",
"prefetch",
"resource hints"
],
"repository": "[email protected]:stimulus-components/stimulus-prefetch.git",
"bugs": {
"url": "https://github.com/stimulus-components/stimulus-prefetch/issues"
},
"author": "Guillaume Briday <[email protected]>",
"license": "MIT",
"homepage": "https://github.com/stimulus-components/stimulus-prefetch",
"private": false,
"esnext": "dist-src/index.js",
"main": "dist-node/index.js",
"module": "dist-web/index.js",
"@pika/pack": {
"pipeline": [
[
"@pika/plugin-standard-pkg"
],
[
"@pika/plugin-build-web"
],
[
"@pika/plugin-build-node"
]
]
},
"scripts": {
"format": "prettier-standard '**/*.{js,css,html}' --format",
"lint": "prettier-standard '**/*.{js,css,html}' --lint",
"dev": "snowpack dev",
"prod": "snowpack build",
"build": "pika build",
"pika:publish": "pika publish --no-tests --no-2fa",
"version": "yarn build"
},
"dependencies": {
"stimulus": "^2.0.0"
},
"devDependencies": {
"@babel/core": "7.12.9",
"@babel/plugin-syntax-class-properties": "7.12.1",
"@babel/preset-env": "7.12.7",
"@pika/pack": "0.5.0",
"@pika/plugin-build-node": "0.9.2",
"@pika/plugin-build-web": "0.9.2",
"@pika/plugin-standard-pkg": "0.9.2",
"@snowpack/plugin-babel": "2.1.5",
"prettier-standard": "16.4.1",
"snowpack": "2.18.1"
}
}
Loading

0 comments on commit 4ac5e48

Please sign in to comment.