Skip to content

Commit f4c9cbf

Browse files
chuckcarpenterRobbieTheWagner
authored andcommitted
chore: Add basic landing page for reloading and contribution (#338)
* chore: Add basic landing page for reloading and contribution * Move dev dep for browserSync * Reset some formatting * Update CONTRIBUTING.md
1 parent 8384628 commit f4c9cbf

File tree

5 files changed

+1061
-32
lines changed

5 files changed

+1061
-32
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ to contribute, we ask that you take the following steps:
2828
1. Most of the _editable_ code lives in the `src` directory while built code
2929
will end up in the `dist` directory upon running `yarn build`.
3030

31-
2. The demo app is served out of the `demo` directory. Running `yarn start` will open it in your browser and initiate a live-reloading session as you make changes.
31+
2. Some examples are served out of the `examples` directory. Running `yarn start` will open the list in your browser and initiate a live-reloading session as you make changes.
3232

3333

3434
## Opening Pull Requests

examples/index.html

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Examples</title>
8+
</head>
9+
<body>
10+
<h3 id="examples">Examples</h3>
11+
<p>It's our goal to create a wide variety of example of how Tether
12+
can be used. Here's what we have so far, please send a PR with
13+
any examples you might create.</p>
14+
<h4 id="beginner">Beginner</h4>
15+
<ul>
16+
<li><a href="./simple">simple</a>: A simple example to get you started</li>
17+
<li><a href="./out-of-bounds">out-of-bounds</a>: How to hide the element when it would
18+
otherwise be offscreen</li>
19+
<li><a href="./pin">pin</a>: How to pin the element so it never goes offscreen</li>
20+
<li><a href="./enable-disable">enable-disable</a>: How to enable and disable the Tether
21+
in JavaScript</li>
22+
</ul>
23+
<h4 id="advanced">Advanced</h4>
24+
<ul>
25+
<li><a href="./content-visible">content-visible</a>: Demonstrates using the <code>'visible'</code>
26+
<code>targetModifier</code> to align an element with the visible portion of another.</li>
27+
<li><a href="./dolls">dolls</a>: A performance test to show several dozen elements,
28+
each tethered to the previous. Try dragging the top left tether.</li>
29+
<li><a href="./element-scroll">element-scroll</a>: Demonstrates using the <code>'scroll-handle'</code>
30+
<code>targetModifier</code> to align an element with the scrollbar of an element.</li>
31+
<li><a href="./scroll">scroll</a>: Demonstrates using the <code>'scroll-handle'</code>
32+
<code>targetModifier</code>
33+
to align an element with the body's scroll handle.</li>
34+
<li><a href="./viewport">viewport</a>: Demonstrates aligning an element with the
35+
viewport by using the <code>'visible'</code> <code>targetModifier</code> when tethered to the body.</li>
36+
</ul>
37+
</body>
38+
</html>

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
"cy:open": "./node_modules/.bin/cypress open",
1818
"cy:run": "./node_modules/.bin/cypress run",
1919
"lint:js": "eslint . --ext js",
20+
"start": "yarn watch",
2021
"start-test-server": "http-server -p 9002",
2122
"test": "yarn lint:js && yarn test:ci",
2223
"test:ci": "yarn test:unit:ci && yarn test:cy:ci",
2324
"test:cy:ci": "yarn build && start-server-and-test start-test-server http://localhost:9002 cy:run",
2425
"test:cy:watch": "yarn build && start-server-and-test start-test-server http://localhost:9002 cy:open",
2526
"test:unit:ci": "jest --coverage",
2627
"test:unit:watch": "jest --watch",
27-
"watch": "rollup --watch"
28+
"watch": "yarn clean && rollup -c --environment DEVELOPMENT --watch"
2829
},
2930
"repository": {
3031
"type": "git",
@@ -55,6 +56,7 @@
5556
"rimraf": "^3.0.0",
5657
"rollup": "^1.21.3",
5758
"rollup-plugin-babel": "^4.3.3",
59+
"rollup-plugin-browsersync": "^1.0.0",
5860
"rollup-plugin-eslint": "^7.0.0",
5961
"rollup-plugin-filesize": "^6.2.0",
6062
"rollup-plugin-license": "^0.12.1",

rollup.config.js

+38-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import autoprefixer from 'autoprefixer';
22
import babel from 'rollup-plugin-babel';
3+
import browsersync from 'rollup-plugin-browsersync';
34
import cssnano from 'cssnano';
45
import { eslint } from 'rollup-plugin-eslint';
56
import filesize from 'rollup-plugin-filesize';
@@ -13,6 +14,8 @@ import fs from 'fs';
1314
const pkg = require('./package.json');
1415
const banner = ['/*!', pkg.name, pkg.version, '*/\n'].join(' ');
1516

17+
const env = process.env.DEVELOPMENT ? 'development' : 'production';
18+
1619
function getSassOptions(minify = false) {
1720
const postcssPlugins = [
1821
autoprefixer({
@@ -45,6 +48,40 @@ function getSassOptions(minify = false) {
4548
};
4649
}
4750

51+
const plugins = [
52+
eslint({
53+
include: '**/*.js'
54+
}),
55+
babel(),
56+
sass(getSassOptions(false)),
57+
license({
58+
banner
59+
}),
60+
filesize(),
61+
visualizer()
62+
];
63+
64+
// If we are running with --environment DEVELOPMENT, serve via browsersync for local development
65+
if (process.env.DEVELOPMENT) {
66+
plugins.push(
67+
browsersync({
68+
host: 'localhost',
69+
watch: true,
70+
port: 3000,
71+
notify: false,
72+
open: true,
73+
server: {
74+
baseDir: 'examples',
75+
routes: {
76+
'/dist/js/tether.js': 'dist/js/tether.js',
77+
'/dist/css/tether-theme-arrows-dark.css':
78+
'dist/css/tether-theme-arrows-dark.css'
79+
}
80+
}
81+
})
82+
);
83+
}
84+
4885
const rollupBuilds = [
4986
{
5087
input: './src/js/tether.js',
@@ -61,18 +98,7 @@ const rollupBuilds = [
6198
sourcemap: true
6299
}
63100
],
64-
plugins: [
65-
eslint({
66-
include: '**/*.js'
67-
}),
68-
babel(),
69-
sass(getSassOptions(false)),
70-
license({
71-
banner
72-
}),
73-
filesize(),
74-
visualizer()
75-
]
101+
plugins
76102
}
77103
];
78104

@@ -104,4 +130,3 @@ rollupBuilds.push({
104130
});
105131

106132
export default rollupBuilds;
107-

0 commit comments

Comments
 (0)