Skip to content

Commit

Permalink
Apply new styles for both Storybook and actual component, per button-…
Browse files Browse the repository at this point in the history
…div differences
  • Loading branch information
michaeljaltamirano committed Jul 16, 2020
1 parent 18030b6 commit d615b7a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ exports[`<OptionButton /> UI snapshots checkbox selected, without custom icon 1`
transition: box-shadow 200ms;
padding: 1.5rem;
margin-bottom: 1rem;
width: 100%;
text-align: left;
}
.emotion-8:hover {
Expand Down Expand Up @@ -131,6 +133,8 @@ exports[`<OptionButton /> UI snapshots radio unselected, with icon node prop 1`]
transition: box-shadow 200ms;
padding: 1.5rem;
margin-bottom: 1rem;
width: 100%;
text-align: left;
}
.emotion-8:hover {
Expand Down
2 changes: 2 additions & 0 deletions src/shared-components/optionButton/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const ClickableContainer = styled.button<{
${({ containerType }) => containerStyles(containerType)};
padding: ${SPACER.large};
margin-bottom: ${SPACER.medium};
width: 100%;
text-align: left;
:focus {
outline: none;
Expand Down
49 changes: 31 additions & 18 deletions stories/optionButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import { OptionButton, Typography } from 'src/shared-components';
import { SPACER } from 'src/constants';

import OptionButtonExample from './optionButtonExample';
import { ExampleContainer } from './style';

const MainContainer = styled.div`
text-align: left;
> h2 {
margin-top: ${SPACER.large};
margin-bottom: ${SPACER.large};
}
`;
Expand All @@ -27,7 +30,7 @@ const FlexContainer = styled.div`
`;

const OptionsContainer = styled.div`
> div {
> button {
width: 350px;
}
`;
Expand Down Expand Up @@ -125,23 +128,33 @@ stories.add(
<Typography.Heading>With Knobs:</Typography.Heading>
<FlexContainer>
<OptionsContainer>
<OptionButton
text={text('text', 'Helper text')}
subtext={text('subtext', 'subtext')}
onClick={noop}
optionType={select('optionType', ['radio', 'checkbox'], 'checkbox')}
buttonType={select('type', ['primary', 'secondary'], 'primary')}
selected={boolean('selected', false)}
/>
<OptionButton
text={text('text', 'Helper text')}
subtext={text('subtext', 'subtext')}
onClick={noop}
optionType={select('optionType', ['radio', 'checkbox'], 'checkbox')}
buttonType={select('type', ['primary', 'secondary'], 'primary')}
selected={boolean('selected', false)}
icon={<AcneGlyph width={32} height={32} />}
/>
<ExampleContainer>
<OptionButton
text={text('text', 'Helper text')}
subtext={text('subtext', 'subtext')}
onClick={noop}
optionType={select(
'optionType',
['radio', 'checkbox'],
'checkbox',
)}
buttonType={select('type', ['primary', 'secondary'], 'primary')}
selected={boolean('selected', false)}
/>
<OptionButton
text={text('text', 'Helper text')}
subtext={text('subtext', 'subtext')}
onClick={noop}
optionType={select(
'optionType',
['radio', 'checkbox'],
'checkbox',
)}
buttonType={select('type', ['primary', 'secondary'], 'primary')}
selected={boolean('selected', false)}
icon={<AcneGlyph width={32} height={32} />}
/>
</ExampleContainer>
</OptionsContainer>
</FlexContainer>
</MainContainer>
Expand Down
12 changes: 3 additions & 9 deletions stories/optionButton/optionButtonExample.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { css } from '@emotion/core';
import { OptionButton } from 'src/shared-components';
import PlusIcon from 'src/svgs/icons/plus-icon.svg';
import MinusIcon from 'src/svgs/icons/minus-icon.svg';
import { ExampleContainer } from './style';

class OptionButtonExample extends React.Component {
state = {
Expand All @@ -19,13 +19,7 @@ class OptionButtonExample extends React.Component {
const { active } = this.state;

return (
<div
css={css`
margin: 0 auto;
max-width: 350px;
padding-top: 40px;
`}
>
<ExampleContainer>
<OptionButton
selected={active === 'improving'}
text="Improving"
Expand All @@ -44,7 +38,7 @@ class OptionButtonExample extends React.Component {
buttonType="primary"
icon={<MinusIcon />}
/>
</div>
</ExampleContainer>
);
}
}
Expand Down
6 changes: 6 additions & 0 deletions stories/optionButton/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import styled from '@emotion/styled';

export const ExampleContainer = styled.div`
margin: 0 auto;
max-width: 350px;
`;

0 comments on commit d615b7a

Please sign in to comment.