Skip to content

Commit

Permalink
Add an introduction to storybook with CSS link
Browse files Browse the repository at this point in the history
- Add an introduction story with rendered README.md

- Add CSS link to README.md

- Ensure dist.zip gets deployed along with Storybook

- Rework gh deployment into a shell script

- Refactor some common story code into lib

- Misc cleanup of old demo files

- Ignore gh-pages for build & test

Fixes FirefoxUX#44
  • Loading branch information
lmorchard committed Oct 23, 2018
1 parent ea91fce commit e3ef3ca
Show file tree
Hide file tree
Showing 24 changed files with 172 additions and 302 deletions.
7 changes: 5 additions & 2 deletions .circleci/config.yml
Expand Up @@ -37,13 +37,16 @@ jobs:
steps:
- attach_workspace:
at: .
- run: npm run deploy:storybook
- run: ./bin/deploy-gh-master.sh

workflows:
version: 2
build_test_deploy:
jobs:
- build
- build:
filters:
branches:
ignore: gh-pages
- storybook_deploy:
requires:
- build
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Expand Up @@ -2,3 +2,4 @@ node_modules
storybook
vendor
dist
deploy
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -5,4 +5,5 @@ npm-debug.log
*.log
*.sw?
*~
dist
dist
deploy
1 change: 1 addition & 0 deletions .storybook/config.js
Expand Up @@ -5,6 +5,7 @@ import "../index.js";
const reqInSrcTree = require.context("../components", true, /\/stories.jsx?$/);

function loadStories() {
require("../stories.js");
reqInSrcTree.keys().forEach(filename => reqInSrcTree(filename));
}

Expand Down
1 change: 1 addition & 0 deletions .stylelintignore
Expand Up @@ -2,4 +2,5 @@ node_modules
storybook
vendor
dist
deploy

8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -8,6 +8,14 @@ These components are intended to be used anywhere where you want to make an HTML

This repository is not intended for a general audience. You do not have to use React to make use of the styles.

## Preview & Download

Preview the latest build from master here:
* <https://firefoxux.github.io/photon-components-web/>

Download the latest build from master here:
* <https://firefoxux.github.io/photon-components-web/dist.zip>

## Development

To get started:
Expand Down
2 changes: 1 addition & 1 deletion attributes/shadows.css
@@ -1,4 +1,4 @@
@import url('../vendor/photon-colors.css');
@import url('~photon-colors/photon-colors.css');

.shadow-10 {
box-shadow: 0 1px 4px var(--grey-90-a10);
Expand Down
20 changes: 20 additions & 0 deletions bin/deploy-gh-master.sh
@@ -0,0 +1,20 @@
#!/bin/bash
set -ex

# Skip builds without credentials
if [[ -z "$GH_TOKEN" ]]; then
echo "Skipping deploy for missing credentials";
exit 0;
fi

rm -rf deploy dist
mkdir deploy
npm run build
cp -r storybook/* deploy/
zip -r deploy/dist.zip dist

./node_modules/.bin/gh-pages \
--silent \
--dist deploy \
--user 'GH Deploy <lorchard@mozilla.com>' \
--repo https://$GH_TOKEN@github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git
23 changes: 2 additions & 21 deletions components/Button/stories.js
@@ -1,28 +1,9 @@
import React from "react";
import { storiesOf } from "@storybook/react";

import { action } from "@storybook/addon-actions";

import { ExtractSource } from "../../.storybook/code-sample";

// TODO: Actually build & use a React component for the markup
// import Button from "./index";
import { Sample } from "../../lib/stories-common";

import "./index.css";
import imageSync from "../../vendor/sync-16.svg";

const actionDefault = msg => ev => {
ev.preventDefault();
action(msg)(ev);
};

const Sample = ({ children, ...props }) => (
<ExtractSource {...props}>
<div className="sample" onClick={actionDefault("clicked")}>
{children}
</div>
</ExtractSource>
);
import imageSync from "./sync-16.svg";

storiesOf("Button", module)
.add("Default", () => (
Expand Down
File renamed without changes
18 changes: 1 addition & 17 deletions components/Card/stories.js
@@ -1,27 +1,11 @@
import React from "react";
import { storiesOf } from "@storybook/react";

import { action } from "@storybook/addon-actions";

import { ExtractSource } from "../../.storybook/code-sample";
import { Sample } from "../../lib/stories-common";

import Card from "./index";

import "./index.css";

const actionDefault = msg => ev => {
ev.preventDefault();
action(msg)(ev);
};

const Sample = ({ children, ...props }) => (
<ExtractSource {...props}>
<div className="sample" onClick={actionDefault("clicked")}>
{children}
</div>
</ExtractSource>
);

storiesOf("Card", module)
.add("Default", () => (
<Sample notes={"This is a very simple Card container."}>
Expand Down
16 changes: 1 addition & 15 deletions components/Link/stories.js
@@ -1,23 +1,9 @@
import React from "react";
import { storiesOf } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import { ExtractSource } from "../../.storybook/code-sample";
import { Sample } from "../../lib/stories-common";

import Link from "./index";

const actionDefault = msg => ev => {
ev.preventDefault();
action(msg)(ev);
};

const Sample = ({ children, ...props }) => (
<ExtractSource {...props}>
<div className="sample" onClick={actionDefault("clicked")}>
{children}
</div>
</ExtractSource>
);

storiesOf("Link", module)
.add("Everything", () => (
<Sample notes={"This is a very simple Link."}>
Expand Down
38 changes: 0 additions & 38 deletions demo/demo.js

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion index.js
@@ -1,6 +1,6 @@
import "photon-colors/photon-colors.css";

import "./base.css";
import "./index.css";

import "./attributes";

Expand Down
16 changes: 16 additions & 0 deletions lib/stories-common.js
@@ -0,0 +1,16 @@
import React from "react";
import { action } from "@storybook/addon-actions";
import { ExtractSource } from "../.storybook/code-sample";

export const actionDefault = msg => ev => {
ev.preventDefault();
action(msg)(ev);
};

export const Sample = ({ children, ...props }) => (
<ExtractSource {...props}>
<div className="sample" onClick={actionDefault("clicked")}>
{children}
</div>
</ExtractSource>
);
96 changes: 96 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e3ef3ca

Please sign in to comment.