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

Rework Group and Inputs #2

Merged
merged 44 commits into from Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f8f5159
Rework Group and Inputs
xdrdak Sep 12, 2019
b880cbb
use styled-system compose function
xdrdak Sep 13, 2019
27e29eb
Merge branch 'master' into rework-group-and-inputs
glambert Sep 18, 2019
7bf24fb
Add layout props to select component
xdrdak Sep 23, 2019
58df4f7
Merge branch 'master' into rework-group-and-inputs
xdrdak Sep 23, 2019
6f8af22
Merge branch 'master' into rework-group-and-inputs
xdrdak Oct 11, 2019
d2423ca
Added back some legacy API for compat reasons and easier migration
xdrdak Oct 11, 2019
987dab2
Add back the legacy group for now
xdrdak Oct 11, 2019
17b278f
Tests for legacy API and component
xdrdak Oct 11, 2019
0aff970
Make codecov less cranky
xdrdak Oct 11, 2019
220f930
Fix checkbox custom component tests
xdrdak Oct 15, 2019
6d3ff8b
Add border props to select
xdrdak Oct 17, 2019
27c5906
Add back border properties to InputWrapper
xdrdak Oct 17, 2019
713f218
Fix input warning story. Force line-height
xdrdak Oct 17, 2019
dd4685c
Adjust a SpacedGroup to match old vertical alignment
xdrdak Oct 17, 2019
848c295
Merge branch 'master' into rework-group-and-inputs
glambert Oct 22, 2019
7f7d193
Merge branch 'master' into rework-group-and-inputs
glambert Oct 23, 2019
11553f9
Move legacy Group back in original folder
glambert Oct 23, 2019
1429a43
Bring back original README and story, add deprecation notice
glambert Oct 23, 2019
a034ec5
Disable eslint no-console errors for deprecation warnings
glambert Oct 23, 2019
5387258
Move InputGroup and SpacedGroup to separate components
glambert Oct 23, 2019
94b010b
Remove unnecessary jest snapshot, Percy will do take care of this
glambert Oct 23, 2019
dbe82f0
Ignore dist/ folder for jest tests
glambert Oct 23, 2019
0b4e3f7
Ignore uncovered lines from coverage
glambert Oct 23, 2019
b655b1b
Adjust Checkbox and Radio stories
glambert Oct 23, 2019
b18eb82
Enable color props on InputGroupAddon component
glambert Oct 24, 2019
4c65656
Remove SpacedGroup component, keep it for stories purpose only
glambert Oct 24, 2019
e55aa8c
Dont show Input status box in suffix if no status, fix FormHelper spa…
glambert Oct 24, 2019
89e0fdd
Add back flameName for Group component compat
glambert Oct 24, 2019
eec23d0
Update snapshots
glambert Oct 24, 2019
16b2ec2
Remove text on Checkbox story for better Percy matching
glambert Oct 24, 2019
ffd4445
Remove disable text on FormField, make Label inline-flex
glambert Oct 24, 2019
4541b38
Update snapshots
glambert Oct 24, 2019
660ed47
Add Dialog story for Percy
glambert Oct 24, 2019
e258ad7
Add back display: flex for BaseLabel
glambert Oct 24, 2019
9e12c71
Put FormHelper top margin at Input level
glambert Oct 24, 2019
a35a4f2
Add README for FormField component
glambert Oct 24, 2019
014fefd
Update CHANGELOG, make sure all base components are exported
glambert Oct 24, 2019
c2b2d1d
Renamed Styled System aliases
glambert Oct 24, 2019
aea7148
Enable zIndex Styled System props on InputGroup-based components
glambert Oct 24, 2019
7054b63
Fix FormField README examples
glambert Oct 25, 2019
7ba4736
Update packages/flame/src/Checkbox/README.md
glambert Oct 25, 2019
73be6ab
Merge branch 'master' into rework-group-and-inputs
glambert Oct 25, 2019
585f4a5
Update FormField README
glambert Oct 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion jest.config.js
@@ -1,6 +1,6 @@
module.exports = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testPathIgnorePatterns: ['<rootDir>/template/', 'dist'],
testPathIgnorePatterns: ['<rootDir>/template/', '/dist/'],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/tests/file-mock.js',
Expand Down
15 changes: 15 additions & 0 deletions packages/flame/CHANGELOG.md
Expand Up @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Refer to the [CONTRIBUTING guide](https://github.com/lightspeed/flame/blob/master/.github/CONTRIBUTING.md) for more info.

## [Unreleased]

### Added

- Add InputGroup and FormField (Label + FormHelper) components ([#2](https://github.com/lightspeed/flame/pull/2))
- Expose Input, Radio and Checkbox base components ([#2](https://github.com/lightspeed/flame/pull/2))

### Changed

- Input no longer uses objects to represent status and status message ([#2](https://github.com/lightspeed/flame/pull/2))

### Deprecated

- Group component will be removed from the next major version of Flame ([#2](https://github.com/lightspeed/flame/pull/2))

## 1.0.0 - 2019-10-08

- Flame is now considered stable :tada:
Expand Down
14 changes: 11 additions & 3 deletions packages/flame/src/Button/BaseButton.tsx
@@ -1,8 +1,9 @@
import { css } from '@emotion/core';
import styled from '@emotion/styled';
import { space, SpaceProps } from 'styled-system';
import { space, SpaceProps, layout, LayoutProps, compose } from 'styled-system';
import { themeGet } from '@styled-system/theme-get';
import { Merge } from 'type-fest';
import { border, BorderProps } from '../Core';

export type ButtonHTML = React.HTMLProps<HTMLButtonElement> & React.HTMLProps<HTMLAnchorElement>;
export type ButtonSizes = 'small' | 'large' | 'xlarge' | 'medium';
Expand All @@ -13,7 +14,9 @@ export type BaseButtonProps = {
disabled?: boolean;
/** Sets display: block on Button */
block?: boolean;
} & SpaceProps;
} & SpaceProps &
LayoutProps &
BorderProps;

const generateSize = (height: number, px: number, font: string, radius: string) => (
props: BaseButtonProps,
Expand Down Expand Up @@ -89,7 +92,12 @@ export const BaseButton = styled('button')<Merge<ButtonHTML, BaseButtonProps>>`
}

${setDisabled};
${space};

${compose(
space,
border,
layout,
)};
`;

BaseButton.defaultProps = {
Expand Down
80 changes: 41 additions & 39 deletions packages/flame/src/Button/story.tsx
Expand Up @@ -7,9 +7,11 @@ import { Button } from './Button';
import Readme from './README.md';
import { Flex, Box } from '../Core';
import { Divider } from '../Divider';
import { Group } from '../Group';
import { InputGroup } from '../InputGroup';
import { Icon } from '../Icon';

import { SpacedGroup } from '../../../../stories/components/SpacedGroup';

const stories = storiesOf('Button', module).addDecorator(withReadme(Readme));

type ButtonPresenterState = {
Expand Down Expand Up @@ -56,15 +58,15 @@ class ButtonPresenter extends PureComponent<{}, ButtonPresenterState> {
stories.add('Styles', () => (
<div>
<h3>Outline</h3>
<Group>
<SpacedGroup>
<Button>Default</Button>
<Button variant="primary">Primary</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="danger">Danger</Button>
</Group>
</SpacedGroup>

<h3>Forced State - Active</h3>
<Group>
<SpacedGroup>
<Button forcedState="active">Default</Button>
<Button variant="primary" forcedState="active">
Primary
Expand All @@ -75,10 +77,10 @@ stories.add('Styles', () => (
<Button variant="danger" forcedState="active">
Danger
</Button>
</Group>
</SpacedGroup>

<h3>Forced State - Hover</h3>
<Group>
<SpacedGroup>
<Button forcedState="hover">Default</Button>
<Button variant="primary" forcedState="hover">
Primary
Expand All @@ -89,10 +91,10 @@ stories.add('Styles', () => (
<Button variant="danger" forcedState="hover">
Danger
</Button>
</Group>
</SpacedGroup>
<hr />
<h3>Fill</h3>
<Group>
<SpacedGroup>
<Button variant="primary" fill>
Primary
</Button>
Expand All @@ -102,10 +104,10 @@ stories.add('Styles', () => (
<Button variant="danger" fill>
Danger
</Button>
</Group>
</SpacedGroup>

<h3>Forced State - Active</h3>
<Group>
<SpacedGroup>
<Button variant="primary" fill forcedState="active">
Primary
</Button>
Expand All @@ -115,10 +117,10 @@ stories.add('Styles', () => (
<Button variant="danger" fill forcedState="active">
Danger
</Button>
</Group>
</SpacedGroup>

<h3>Forced State - Hover</h3>
<Group>
<SpacedGroup>
<Button variant="primary" fill forcedState="hover">
Primary
</Button>
Expand All @@ -128,14 +130,14 @@ stories.add('Styles', () => (
<Button variant="danger" fill forcedState="hover">
Danger
</Button>
</Group>
</SpacedGroup>
</div>
));

stories.add('Sizes', () => (
<div>
<Box mb={3}>
<Group>
<SpacedGroup>
<Button size="small">Small</Button>
<Button variant="primary">Medium</Button>
<Button variant="secondary" size="large">
Expand All @@ -144,10 +146,10 @@ stories.add('Sizes', () => (
<Button variant="danger" size="xlarge">
Extra Large
</Button>
</Group>
</SpacedGroup>
</Box>
<Box mb={3}>
<Group type="vertical">
<SpacedGroup flexDirection="column">
<Button size="small" block>
Small Block
</Button>
Expand All @@ -160,7 +162,7 @@ stories.add('Sizes', () => (
<Button variant="danger" size="xlarge" block>
Extra Large Block
</Button>
</Group>
</SpacedGroup>
</Box>
<Divider mt={3} />
<h3>Multiline</h3>
Expand Down Expand Up @@ -208,7 +210,7 @@ stories.add('Button as Links', () => (
stories.add('Events', () => (
<div>
<Box mb={3}>
<Group type="vertical">
<SpacedGroup flexDirection="column">
<Button onClick={action('Clicked')}>Button with onClick event (see Action Logger)</Button>
<Button onFocus={action('Focused')}>Button with onFocus event (see Action Logger)</Button>
<Button onBlur={action('Blured')}>Button with onBlur event (see Action Logger)</Button>
Expand All @@ -227,56 +229,56 @@ stories.add('Events', () => (
<Button href="http://google.com" target="_blank" disabled>
Disabled link removes href and target
</Button>
</Group>
</SpacedGroup>
</Box>
</div>
));

stories.add('With Children', () => (
<div>
<Box mb={3}>
<Group>
<SpacedGroup>
<Button size="small">
<Icon name="orders" />
</Button>
<Button>
<Icon name="orders" />
</Button>
<Group noSpacing>
<InputGroup>
<Button>
<Icon name="small-chevron-left" />
</Button>
<Button>
<Icon name="small-chevron-right" />
</Button>
</Group>
</InputGroup>
<Button size="large">
<Icon name="orders" />
</Button>
<Button size="xlarge">
<Icon name="orders" />
</Button>
</Group>
</SpacedGroup>
</Box>
<Box mb={3}>
<Group>
<SpacedGroup>
<Button variant="primary">
<Icon name="chevron-left" /> Back
</Button>
<Button variant="primary" fill>
<Icon name="dashboard" /> Dashboard
</Button>
</Group>
</SpacedGroup>
</Box>
<Box mb={3}>
<Group>
<SpacedGroup>
<Button variant="secondary">
View Product <Icon name="arrow-right" />
</Button>
<Button variant="secondary" fill>
Customers <Icon name="customers" />
</Button>
</Group>
</SpacedGroup>
</Box>
<Box mb={3}>
<Button variant="danger">
Expand All @@ -287,7 +289,7 @@ stories.add('With Children', () => (
</Button>
</Box>
<Box mb={3}>
<Group type="vertical">
<SpacedGroup flexDirection="column">
<Button size="small" block>
<Icon name="users" /> Small Block
</Button>
Expand All @@ -301,15 +303,15 @@ stories.add('With Children', () => (
<Icon name="support-tickets" /> Large Block
</Button>
<Button size="xlarge" block>
Extra Large Block with Lightspeed logo
Extra Large Block
</Button>
<Button size="xlarge" block>
<Icon name="image" size="xsmall" /> Custom icon size in Extra Large Block
</Button>
</Group>
</SpacedGroup>
</Box>
<Box mb={3}>
<Group type="vertical">
<SpacedGroup flexDirection="column">
<Button size="small" block>
<Icon name="users" /> Small Block
</Button>
Expand All @@ -323,16 +325,16 @@ stories.add('With Children', () => (
<Icon name="support-tickets" /> Large Block
</Button>
<Button size="xlarge" block>
Extra Large Block with Lightspeed logo
Extra Large Block
</Button>
<Button size="xlarge" block>
<Icon name="image" size="xsmall" /> Custom icon size in Extra Large Block
</Button>
</Group>
</SpacedGroup>
</Box>
<Box mb={3}>
<h3>Icons with details should be colored properly</h3>
<Group>
<SpacedGroup>
<Button variant="primary" fill>
<Icon name="dashboard" /> Dashboard
</Button>
Expand All @@ -345,15 +347,15 @@ stories.add('With Children', () => (
<Button fill>
<Icon name="dashboard" /> Dashboard
</Button>
</Group>
</SpacedGroup>
</Box>
</div>
));

stories.add('Loading', () => (
<div>
<Box mb={3}>
<Group>
<SpacedGroup>
<Button loading>Default</Button>
<Button variant="primary" loading>
Primary
Expand All @@ -364,10 +366,10 @@ stories.add('Loading', () => (
<Button variant="danger" loading>
Danger
</Button>
</Group>
</SpacedGroup>
</Box>
<Box mb={3}>
<Group>
<SpacedGroup>
<Button size="small" variant="primary" fill loading>
Primary
</Button>
Expand All @@ -377,7 +379,7 @@ stories.add('Loading', () => (
<Button size="xlarge" variant="danger" fill loading>
Danger
</Button>
</Group>
</SpacedGroup>
</Box>
<Box mb={3}>
<ButtonPresenter />
Expand Down
13 changes: 5 additions & 8 deletions packages/flame/src/Checkbox/Checkbox.test.tsx
Expand Up @@ -12,8 +12,8 @@ type RenderTest = {
indeterminate?: boolean;
id?: string;
value?: string;
label?: string | Function;
description?: string | Function;
label?: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string | Function | React.Element?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a test file so I don't think its worth 😉

description?: any;
};
};

Expand All @@ -34,8 +34,8 @@ describe('<Checkbox />', () => {
props: {
id: 'id',
value: 'value',
label: () => <div>Label</div>,
description: () => <div>Description</div>,
label: <div>Label</div>,
description: <div>Description</div>,
},
},
];
Expand Down Expand Up @@ -82,10 +82,7 @@ describe('<Checkbox />', () => {

it('renders custom components in Label and Description', () => {
const { getByText } = customRender(
<Checkbox
label={() => <div>my label</div>}
description={() => <div>my description</div>}
/>,
<Checkbox label={<div>my label</div>} description={<div>my description</div>} />,
);

getByText('my label');
Expand Down