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

Use css-in-js for styling in navigation component #24522

Merged
merged 4 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
9 changes: 7 additions & 2 deletions packages/components/src/navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
*/
import { useEffect, useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import { Root } from './styles/navigation-styles';

const Navigation = ( { activeItemId, children, data, rootTitle } ) => {
const [ activeLevel, setActiveLevel ] = useState( 'root' );

Expand Down Expand Up @@ -35,14 +40,14 @@ const Navigation = ( { activeItemId, children, data, rootTitle } ) => {
}, [] );

return (
<div className="components-navigation">
<Root className="components-navigation">
{ children( {
level,
levelItems,
parentLevel,
setActiveLevel,
} ) }
</div>
</Root>
);
};

Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/navigation/menu-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Icon, chevronRight } from '@wordpress/icons';
* Internal dependencies
*/
import Button from '../button';
import { MenuItem } from './styles/navigation-styles';
import Text from '../text';

const NavigationMenuItem = ( props ) => {
Expand All @@ -37,14 +38,14 @@ const NavigationMenuItem = ( props ) => {
};

return (
<li className={ classes }>
<MenuItem className={ classes }>
<Button className={ classes } onClick={ handleClick }>
<Text variant="body.small">
<span>{ title }</span>
</Text>
{ hasChildren ? <Icon icon={ chevronRight } /> : null }
</Button>
</li>
</MenuItem>
);
};

Expand Down
7 changes: 6 additions & 1 deletion packages/components/src/navigation/menu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/**
* Internal dependencies
*/
import { Menu } from './styles/navigation-styles';

const NavigationMenu = ( { children } ) => {
return <ul className="components-navigation__menu">{ children }</ul>;
return <Menu className="components-navigation__menu">{ children }</Menu>;
};

export default NavigationMenu;
26 changes: 0 additions & 26 deletions packages/components/src/navigation/style.scss

This file was deleted.

37 changes: 37 additions & 0 deletions packages/components/src/navigation/styles/navigation-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* External dependencies
*/
import styled from '@emotion/styled';

const horizontalPadding = '30px';

export const Root = styled.div`
width: 272px;
joshuatf marked this conversation as resolved.
Show resolved Hide resolved
padding: 35px 0px;
joshuatf marked this conversation as resolved.
Show resolved Hide resolved
> *:not( .components-navigation__menu ) {
joshuatf marked this conversation as resolved.
Show resolved Hide resolved
margin-left: ${ horizontalPadding };
margin-right: ${ horizontalPadding };
joshuatf marked this conversation as resolved.
Show resolved Hide resolved
}
`;

export const Menu = styled.ul`
padding: 0;
margin: 0 0 32px 0;
display: flex;
flex-direction: column;
`;

export const MenuItem = styled.li`
joshuatf marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
joshuatf marked this conversation as resolved.
Show resolved Hide resolved
justify-content: space-between;
button {
width: 100%;
padding-top: 8px;
padding-bottom: 8px;
padding-left: ${ horizontalPadding };
padding-right: ${ horizontalPadding };
}
&.is-active span {
border-bottom: 2px solid var( --wp-admin-theme-color );
}
`;
1 change: 0 additions & 1 deletion packages/components/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
@import "./menu-item/style.scss";
@import "./menu-items-choice/style.scss";
@import "./modal/style.scss";
@import "./navigation/style.scss";
@import "./notice/style.scss";
@import "./panel/style.scss";
@import "./placeholder/style.scss";
Expand Down