-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from saucal/feature/refactor-plugin-navigation
Feature/refactor plugin navigation
- Loading branch information
Showing
54 changed files
with
36,088 additions
and
1,022 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { NavigableMenu } from '@wordpress/components'; | ||
import { Link } from '@woocommerce/components'; | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
|
||
const TabLink = ( { tabId, href, children, selected, ...rest } ) => { | ||
return ( | ||
<Link | ||
role="tab" | ||
tabIndex={ selected ? null : -1 } | ||
aria-selected={ selected } | ||
id={ tabId } | ||
href={ href } | ||
{ ...rest } | ||
> | ||
{ children } | ||
</Link> | ||
); | ||
}; | ||
|
||
const AppTabNav = ( props ) => { | ||
const { selectedKey, tabs } = props; | ||
|
||
return ( | ||
<div className="app-tab-nav"> | ||
<NavigableMenu | ||
role="tablist" | ||
orientation="horizontal" | ||
className="app-tab-nav__tabs" | ||
> | ||
{ tabs.map( ( tab ) => ( | ||
<TabLink | ||
className={ classnames( | ||
'components-button', | ||
'app-tab-nav__tabs-item', | ||
{ | ||
'is-active': tab.key === selectedKey, | ||
} | ||
) } | ||
tabId={ `${ tab.key }` } | ||
aria-controls={ `${ tab.key }-view` } | ||
selected={ tab.key === selectedKey } | ||
key={ tab.key } | ||
href={ tab.href } | ||
> | ||
{ tab.title } | ||
</TabLink> | ||
) ) } | ||
</NavigableMenu> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AppTabNav; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
.app-tab-nav__tabs { | ||
display: flex; | ||
align-items: stretch; | ||
box-shadow: inset 0 -1px 0 #ccc; | ||
margin-bottom: var(--main-gap); | ||
|
||
&-item { | ||
background: transparent; | ||
border: none; | ||
box-shadow: none; | ||
border-radius: 0; | ||
cursor: pointer; | ||
height: 48px; | ||
padding: 3px 16px; // Use padding to offset the is-active border, this benefits Windows High Contrast mode | ||
margin-left: 0; | ||
font-weight: 500; | ||
//transition: box-shadow 0.1s linear; | ||
box-sizing: border-box; | ||
|
||
// This pseudo-element "duplicates" the tab label and sets the text to bold. | ||
// This ensures that the tab doesn't change width when selected. | ||
// See: https://github.com/WordPress/gutenberg/pull/9793 | ||
&::after { | ||
content: attr(data-label); | ||
display: block; | ||
height: 0; | ||
overflow: hidden; | ||
speak: none; | ||
visibility: hidden; | ||
} | ||
|
||
&:focus:not(:disabled) { | ||
box-shadow: inset 0 2px var(--wp-admin-theme-color); | ||
} | ||
|
||
&.is-active { | ||
// The transparent shadow ensures no jumpiness when focus animates on an active tab. | ||
box-shadow: inset 0 0 0 2px transparent, inset 0 -4px 0 0 var(--wp-admin-theme-color); | ||
position: relative; | ||
|
||
// This border appears in Windows High Contrast mode instead of the box-shadow. | ||
&::before { | ||
content: ""; | ||
position: absolute; | ||
top: 0; | ||
bottom: 1px; | ||
right: 0; | ||
left: 0; | ||
border-bottom: 4px solid transparent; | ||
} | ||
} | ||
|
||
&:focus { | ||
box-shadow: inset 0 0 0 2px var(--wp-admin-theme-color); | ||
} | ||
|
||
&.is-active:focus { | ||
box-shadow: inset 0 0 0 2px var(--wp-admin-theme-color), inset 0 0 -4px 0 0 var(--wp-admin-theme-color); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import MainTabNav from './main-tab-nav'; | ||
|
||
/** | ||
* Display tab-based navigation when the new WC Navigation is not enabled. | ||
* | ||
* @return {import("./main-tab-nav")} Retuns MainTabNav if WC Navigation is not enabled. | ||
*/ | ||
const NavigationClassic = () => { | ||
const navigationEnabled = !! window.wcAdminFeatures?.navigation; | ||
|
||
return navigationEnabled ? null : <MainTabNav />; | ||
}; | ||
|
||
export default NavigationClassic; |
Oops, something went wrong.