Skip to content

Commit

Permalink
feat(Menu): updates menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Firsov committed Oct 5, 2018
1 parent 79a4968 commit 4ab8592
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 46 deletions.
9 changes: 8 additions & 1 deletion src/atoms/Menu/Menu.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ import React from 'react';
export default (asStory) => {
asStory('ATOMS/Menu', module, (story, { Menu }) => {
story
.add('with default modifiers', () => (
.add('s size', () => (
<Menu.Plate>
<Menu.Item>Tramman</Menu.Item>
<Menu.Item>Gripman</Menu.Item>
<Menu.Item>Proalliance</Menu.Item>
</Menu.Plate>
))
.add('m size', () => (
<Menu.Plate size="m">
<Menu.Item>Tramman</Menu.Item>
<Menu.Item>Gripman</Menu.Item>
<Menu.Item>Proalliance</Menu.Item>
</Menu.Plate>
));
});
};
48 changes: 34 additions & 14 deletions src/atoms/Menu/MenuItem.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,63 @@
import React from 'react';

import { createStyledTag, createTheme } from '../../utils';
import { GREY_COLORS } from '../../theme/dsmColors';
import { SizeContext } from './SizeContext';

type MenuItemProps = {|
children?: React$Node,
|};

const name = 'menuItem';
const NAME = 'menuItem';

const theme = createTheme(name, {
const theme = createTheme(NAME, {
modifiers: {
size: {
s: {
height: '3.2rem',
lineHeight: '3.2rem',
paddingRight: '1.6rem',
paddingLeft: '1.6rem',
},
m: {
height: '4rem',
lineHeight: '2.3rem',
paddingRight: '1.9rem',
paddingLeft: '1.9rem',
},
},
},
defaults: {
size: 's',
},
});

const StyledTag = createStyledTag(name, () => ({
color: 'rgba(0, 0, 0, 0.87)',
const StyledTag = createStyledTag(NAME, () => ({
color: GREY_COLORS.DARK_GREY_2,
fontFamily: 'Poppins',
fontSize: '14px',
fontWeight: 400,
height: '2rem',
display: 'flex',
alignItems: 'center',
cursor: 'pointer',
padding: '0 1rem',
whiteSpace: 'nowrap',

'&:hover': {
backgroundColor: '#4DA1FF',
color: '#fff',
backgroundColor: GREY_COLORS.LIGHT_GREY_3,
color: GREY_COLORS.BLACK,
},
}));

function MenuItem({
children,
...rest
}: MenuItemProps) {
return <StyledTag { ...rest } tagName="div">{ children }</StyledTag>;
}
const MenuItem = ({ children, ...rest }: MenuItemProps) => (
<SizeContext.Consumer>
{ size => (
<StyledTag tagName="div" size={ size } { ...rest } >
{ children }
</StyledTag>
) }
</SizeContext.Consumer>
);

MenuItem.displayName = 'Menu.Item';

export { MenuItem, theme };
44 changes: 30 additions & 14 deletions src/atoms/Menu/MenuPlate.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,52 @@
import React from 'react';

import { createStyledTag, createTheme } from '../../utils';
import { GREY_COLORS } from '../../theme/dsmColors';
import { SizeContext } from './SizeContext';

type MenuPlateProps = {|
children?: React$Node,
size?: 's' | 'm',
|};

const name = 'menuPlate';
const NAME = 'menuPlate';

const theme = createTheme(name, {
const theme = createTheme(NAME, {
modifiers: {
size: {
s: {
borderRadius: '0 0 .5rem .5rem',
},
m: {
marginTop: '.8rem',
paddingTop: '.8rem',
paddingBottom: '.8rem',
borderRadius: '.5rem',
boxShadow: '0 .4rem .8rem 0 rgba(0, 0, 0, 0.04)',
},
},
},
defaults: {
size: 's',
},
});

const StyledTag = createStyledTag(name, () => ({
const StyledTag = createStyledTag(NAME, () => ({
backgroundColor: '#fff',
border: '1px solid #d0d7dd',
borderRadius: '5px',
padding: '1rem 0',
boxSizing: 'border-box',
border: `.1rem solid ${GREY_COLORS.LIGHT_GREY_1}`,
display: 'flex',
flexDirection: 'column',
}));

function MenuPlate({
children,
...rest
}: MenuPlateProps) {
return (
<StyledTag { ...rest } tagName="div">{ children }</StyledTag>
);
}
const MenuPlate = ({ children, ...rest }: MenuPlateProps) => (
<StyledTag tagName="div" { ...rest } >
<SizeContext.Provider value={ rest.size }>
{ children }
</SizeContext.Provider>
</StyledTag>
);

MenuPlate.displayName = 'Menu.Plate';

export { MenuPlate, theme };
4 changes: 4 additions & 0 deletions src/atoms/Menu/SizeContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createContext } from 'react';

export const SizeContext = createContext();

37 changes: 37 additions & 0 deletions src/theme/dsmColors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export const GREY_COLORS = {
BLACK: '#323c47',
DARK_GREY_1: '#7e828b',
DARK_GREY_2: '#939ea7',
DARK_GREY_3: '#a5afb6',
LIGHT_GREY_1: '#d0d7dd',
LIGHT_GREY_2: '#e9eff4',
LIGHT_GREY_3: '#f4f5f6',
};

export const MAIN_BRAND_COLORS = {
BLUE: '#4da1ff',
CHARCOAL: '#323c47',
RED: '#eb4235',
YELLOW: '#ffd012',
};

export const NAVIGATION_COLORS = {
DB: '#323c47',
DB_SELECTED: '#1c252e',
HOME: '#4da1ff',
HOME_SELECTED: '#1f7ae0',
SETTINGS: '#687695',
SETTINGS_SELECTED: '#4d5a78',
};

export const SECONDARY_COLORS = {
CORAL: '#f17b71',
DARK_BLUE: '#1968cb',
GREEN: '#00bb6e',
MAGENTA: '#ea518e',
NEON: '#a6e50f',
ORANGE: '#ff6d4a',
PURPLE: '#9975d0',
SPACE: '#687695',
};

112 changes: 95 additions & 17 deletions storybook/__tests__/__snapshots__/storyshots.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10379,24 +10379,23 @@ exports[`Storyshots ATOMS/Dropdown with menu 1`] = `
.emotion-6 {
background-color: #fff;
border: 1px solid #d0d7dd;
border-radius: 5px;
padding: 1rem 0;
box-sizing: border-box;
border: .1rem solid #d0d7dd;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
border-radius: 0 0 .5rem .5rem;
}
.emotion-3 {
color: rgba(0,0,0,0.87);
color: #939ea7;
font-family: Poppins;
font-size: 14px;
font-weight: 400;
height: 2rem;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand All @@ -10406,13 +10405,16 @@ exports[`Storyshots ATOMS/Dropdown with menu 1`] = `
-ms-flex-align: center;
align-items: center;
cursor: pointer;
padding: 0 1rem;
white-space: nowrap;
height: 3.2rem;
line-height: 3.2rem;
padding-right: 1.6rem;
padding-left: 1.6rem;
}
.emotion-3:hover {
background-color: #4DA1FF;
color: #fff;
background-color: #f4f5f6;
color: #323c47;
}
<div
Expand Down Expand Up @@ -12731,31 +12733,34 @@ exports[`Storyshots ATOMS/Loader with various size 1`] = `
</div>
`;

exports[`Storyshots ATOMS/Menu with default modifiers 1`] = `
exports[`Storyshots ATOMS/Menu m size 1`] = `
.emotion-4 {
margin: 2rem;
}
.emotion-3 {
background-color: #fff;
border: 1px solid #d0d7dd;
border-radius: 5px;
padding: 1rem 0;
box-sizing: border-box;
border: .1rem solid #d0d7dd;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
margin-top: .8rem;
padding-top: .8rem;
padding-bottom: .8rem;
border-radius: .5rem;
box-shadow: 0 .4rem .8rem 0 rgba(0,0,0,0.04);
}
.emotion-0 {
color: rgba(0,0,0,0.87);
color: #939ea7;
font-family: Poppins;
font-size: 14px;
font-weight: 400;
height: 2rem;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand All @@ -12765,13 +12770,86 @@ exports[`Storyshots ATOMS/Menu with default modifiers 1`] = `
-ms-flex-align: center;
align-items: center;
cursor: pointer;
padding: 0 1rem;
white-space: nowrap;
height: 4rem;
line-height: 2.3rem;
padding-right: 1.9rem;
padding-left: 1.9rem;
}
.emotion-0:hover {
background-color: #4DA1FF;
color: #fff;
background-color: #f4f5f6;
color: #323c47;
}
<div
className="emotion-4"
>
<div
className="emotion-3"
>
<div
className="emotion-0"
>
Tramman
</div>
<div
className="emotion-0"
>
Gripman
</div>
<div
className="emotion-0"
>
Proalliance
</div>
</div>
</div>
`;

exports[`Storyshots ATOMS/Menu s size 1`] = `
.emotion-4 {
margin: 2rem;
}
.emotion-3 {
background-color: #fff;
box-sizing: border-box;
border: .1rem solid #d0d7dd;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
border-radius: 0 0 .5rem .5rem;
}
.emotion-0 {
color: #939ea7;
font-family: Poppins;
font-size: 14px;
font-weight: 400;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
cursor: pointer;
white-space: nowrap;
height: 3.2rem;
line-height: 3.2rem;
padding-right: 1.6rem;
padding-left: 1.6rem;
}
.emotion-0:hover {
background-color: #f4f5f6;
color: #323c47;
}
<div
Expand Down

0 comments on commit 4ab8592

Please sign in to comment.