Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Component-driven React / Vue / Angular / Preact / Svelte templates #11505

Merged
merged 23 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1b2f4ab
CLI: Update React JS template with Header/Page stories
shilman Jul 11, 2020
3282fc1
Merge branch 'next' into 10723-update-cli-template-stories
shilman Jul 11, 2020
f8531a3
CLI: React template Button onClick
shilman Jul 11, 2020
fddc9a1
CLI: React template Button css
shilman Jul 11, 2020
b67c65f
add e2e target
tooppaaa Jul 11, 2020
0f94327
Vue stories
tooppaaa Jul 13, 2020
e0d531b
CLI template: Fix button CSS
shilman Jul 14, 2020
c06b9e9
CLI template: Link to componentdriven.org
shilman Jul 14, 2020
b5e6985
Fix typo
shilman Jul 14, 2020
f6e7ddf
CLI: Ignore import/extensions for framework templates
shilman Jul 14, 2020
1e6a38e
Preact CLI
tooppaaa Jul 14, 2020
25089c1
Angular CLI
tooppaaa Jul 14, 2020
b101f9e
Merge branch 'next' into 10723-update-cli-template-stories
shilman Jul 15, 2020
bfa4926
CLI template: Fix componentdriven.org link
shilman Jul 15, 2020
45f7ec2
CLI template: Use action argType instead of hard-coded action
shilman Jul 15, 2020
fba408c
CLI template: Prettier
shilman Jul 15, 2020
ed2e2ed
CLI: Fix Angular template compodoc settings
shilman Jul 15, 2020
af5337e
Merge branch 'next' into 10723-update-cli-template-stories
shilman Jul 15, 2020
8026f60
Merge branch 'next' into 10723-update-cli-template-stories
shilman Jul 15, 2020
2302d7a
CLI: Fix Vue CLI template props handing
shilman Jul 15, 2020
fec9066
Svelte CLI
tooppaaa Jul 15, 2020
aa1d6ba
Merge branch 'next' into 10723-update-cli-template-stories
shilman Jul 16, 2020
bca9750
Fix capitalization
shilman Jul 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions lib/cli/src/frameworks/react/js/1-Button.stories.js

This file was deleted.

83 changes: 83 additions & 0 deletions lib/cli/src/frameworks/react/js/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react';
import PropTypes from 'prop-types';

const baseStyles = {
shilman marked this conversation as resolved.
Show resolved Hide resolved
fontFamily: '"Nunito Sans", "Helvetica Neue", Helvetica, Arial, sans-serif',
fontWeight: 700,

border: 0,
borderRadius: '3em',
cursor: 'pointer',
display: 'inline-block',
lineHeight: 1,
};

const modeStyles = {
primary: {
color: 'white',
backgroundColor: '#1EA7FD',
},
secondary: {
color: '#333',
backgroundColor: 'transparent',
boxShadow: 'rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset',
},
};

const sizeStyles = {
small: {
fontSize: '12px',
padding: '10px 16px',
},
medium: {
fontSize: '14px',
padding: '11px 20px',
},
large: {
fontSize: '16px',
padding: '12px 24px',
},
};

/**
* Primary UI component for user interaction
*/
export const Button = ({ primary, backgroundColor, size, label, ...props }) => (
<button
type="button"
style={{
...baseStyles,
...modeStyles[primary ? 'primary' : 'secondary'],
...sizeStyles[size],
...(backgroundColor && { backgroundColor }),
}}
{...props}
>
{label}
</button>
);

Button.propTypes = {
/**
* Is this the principal call to action on the page?
*/
primary: PropTypes.bool,
/**
* What background color to use
*/
backgroundColor: PropTypes.string,
/**
* How large should the button be?
*/
size: PropTypes.oneOf(Object.keys(sizeStyles)),
/**
* Button contents
*/
label: PropTypes.string.isRequired,
};

Button.defaultProps = {
backgroundColor: null,
primary: false,
size: 'medium',
};
17 changes: 0 additions & 17 deletions lib/cli/src/frameworks/react/js/Button.jsx

This file was deleted.

36 changes: 36 additions & 0 deletions lib/cli/src/frameworks/react/js/Button.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';

import { Button } from './Button';

export default {
title: 'Example/Button',
component: Button,
argTypes: {
backgroundColor: { control: 'color' },
},
};

const Template = (args) => <Button {...args} />;

export const Primary = Template.bind({});
Primary.args = {
primary: true,
label: 'Button',
};

export const Secondary = Template.bind({});
Secondary.args = {
label: 'Button',
};

export const Large = Template.bind({});
Large.args = {
size: 'large',
label: 'Button',
};

export const Small = Template.bind({});
Small.args = {
size: 'small',
label: 'Button',
};
81 changes: 81 additions & 0 deletions lib/cli/src/frameworks/react/js/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React from 'react';
import PropTypes from 'prop-types';

import { Button } from './Button';

const css = `
.wrapper {
font-family: "Nunito Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
border-bottom: 1px solid rgba(0,0,0,.1);
padding: 15px 20px;
display: flex;
align-items: center;
justify-content: space-between;
}

svg {
display: inline-block;
vertical-align: top;
}

h1 {
font-weight: 900;
font-size: 20px;
line-height: 1;
margin: 6px 0 6px 10px;
display: inline-block;
vertical-align: top;
}

button + button {
margin-left: 10px;
}
`;

export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (
<header>
<style>{css}</style>
<div className="wrapper">
<div>
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fillRule="evenodd">
<path
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
fill="#FFF"
/>
<path
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
fill="#555AB9"
/>
<path
d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
fill="#91BAF8"
/>
</g>
</svg>
<h1>Acme</h1>
</div>
<div>
{user ? (
<Button size="small" onClick={onLogout} label="Log out" />
) : (
<>
<Button size="small" onClick={onLogin} label="Log in" />
<Button primary size="small" onClick={onCreateAccount} label="Sign up" />
</>
)}
</div>
</div>
</header>
);

Header.propTypes = {
user: PropTypes.shape({}),
onLogin: PropTypes.func.isRequired,
onLogout: PropTypes.func.isRequired,
onCreateAccount: PropTypes.func.isRequired,
};

Header.defaultProps = {
user: null,
};
18 changes: 18 additions & 0 deletions lib/cli/src/frameworks/react/js/Header.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';

import { Header } from './Header';

export default {
title: 'Example/Header',
component: Header,
};
shilman marked this conversation as resolved.
Show resolved Hide resolved

const Template = (args) => <Header {...args} />;

export const LoggedIn = Template.bind({});
LoggedIn.args = {
user: {},
};

export const LoggedOut = Template.bind({});
LoggedOut.args = {};
Loading