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 all 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 { 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