Skip to content

Commit

Permalink
Use css-in-js for styling in navigation component (#24522)
Browse files Browse the repository at this point in the history
* Migrate styles to css-in-js

* Add spacing to navigation child items

* Remove opinionated styling

* Rename styling components
  • Loading branch information
joshuatf authored and psealock committed Aug 31, 2020
1 parent c08901d commit 63736b4
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 32 deletions.
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 { MenuItemUI } from './styles/navigation-styles';
import Text from '../text';

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

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

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

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

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

This file was deleted.

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

export const Root = styled.div`
width: 100%;
`;

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

export const MenuItemUI = styled.li`
button {
width: 100%;
}
&.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

0 comments on commit 63736b4

Please sign in to comment.