Skip to content

Commit

Permalink
Add default styles to the TabPanel component (#20872)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Mar 13, 2020
1 parent 7eaf250 commit a38de90
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/components/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
@import "./select-control/style.scss";
@import "./snackbar/style.scss";
@import "./spinner/style.scss";
@import "./tab-panel/style.scss";
@import "./text-control/style.scss";
@import "./textarea-control/style.scss";
@import "./tip/style.scss";
Expand Down
10 changes: 7 additions & 3 deletions packages/components/src/tab-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ class TabPanel extends Component {
>
{ tabs.map( ( tab ) => (
<TabButton
className={ classnames( tab.className, {
[ activeClass ]: tab.name === selected,
} ) }
className={ classnames(
'components-tab-panel__tabs-item',
tab.className,
{
[ activeClass ]: tab.name === selected,
}
) }
tabId={ instanceId + '-' + tab.name }
aria-controls={
instanceId + '-' + tab.name + '-view'
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/tab-panel/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const _default = () => {
return (
<TabPanel
className="my-tab-panel"
activeClass="active-tab"
tabs={ [
{
name: 'tab1',
Expand Down
44 changes: 44 additions & 0 deletions packages/components/src/tab-panel/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.components-tab-panel__tabs {
display: flex;
align-items: stretch;
}

.components-tab-panel__tabs-item {
background: transparent;
border: none;
border-radius: 0;
box-shadow: none;
cursor: pointer;
height: 50px;
padding: 3px 15px; // Use padding to offset the is-active border, this benefits Windows High Contrast mode
margin-left: 0;
font-weight: 400;
@include square-style__neutral;
transition: box-shadow 0.1s linear;

&:focus:enabled {
color: $dark-gray-900;
outline-offset: -1px;
outline: 1px dotted $dark-gray-500;
}

&:focus:enabled,
&.is-active {
box-shadow: inset 0 -3px theme(outlines);
font-weight: 600;
position: relative;
background: transparent;

// 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: 3px solid transparent;
}
}

}
4 changes: 2 additions & 2 deletions storybook/test/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7893,7 +7893,7 @@ exports[`Storyshots Components/TabPanel Default 1`] = `
<button
aria-controls="0-tab1-view"
aria-selected={true}
className="components-button tab-one active-tab"
className="components-button components-tab-panel__tabs-item tab-one is-active"
id="0-tab1"
onClick={[Function]}
role="tab"
Expand All @@ -7905,7 +7905,7 @@ exports[`Storyshots Components/TabPanel Default 1`] = `
<button
aria-controls="0-tab2-view"
aria-selected={false}
className="components-button tab-two"
className="components-button components-tab-panel__tabs-item tab-two"
id="0-tab2"
onClick={[Function]}
role="tab"
Expand Down

0 comments on commit a38de90

Please sign in to comment.