-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
423 additions
and
648 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
src/components/Tabs/Tab/__tests__/__snapshots__/Tab.spec.js.snap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/components/Tabs/TabContent/__tests__/TabContent.spec.js
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
src/components/Tabs/TabContent/__tests__/__snapshots__/TabContent.spec.js.snap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,49 +1,42 @@ | ||
.TabItem { | ||
background-color: var(--color-neutral-25); | ||
border: { | ||
color: var(--color-neutral); | ||
style: solid; | ||
top-left-radius: var(--border-radius); | ||
top-right-radius: var(--border-radius); | ||
width: var(--line-normal); | ||
bottom-width: 0; | ||
} | ||
color: var(--link-color-normal); | ||
cursor: pointer; | ||
font: { | ||
family: var(--font-family-primary); | ||
size: var(--font-size-normal); | ||
} | ||
margin: { | ||
top: var(--margin); | ||
right: var(--margin); | ||
left: var(--margin); | ||
}; | ||
outline: none; | ||
padding: var(--spacing-2x) var(--spacing-4x); | ||
line-height: var(--line-height-normal); | ||
text-decoration: none; | ||
transition: border-color var(--transition-duration); | ||
transition: all var(--transition-duration); | ||
text-align: center; | ||
border-bottom: 4px solid transparent; | ||
margin-bottom: -1px; | ||
font-weight: var(--font-weight-bold); | ||
|
||
&:hover { | ||
border-color: var(--color-neutral-60); | ||
border-bottom: 4px solid var(--color-neutral-25); | ||
color: var(--link-color-hover); | ||
} | ||
|
||
&:first-child { | ||
margin-left: 0; | ||
&--isActive { | ||
cursor: default; | ||
color: var(--color-foreground); | ||
border-bottom: 4px solid var(--color-brand); | ||
|
||
&:hover { | ||
color: var(--color-foreground); | ||
border-bottom: 4px solid var(--color-brand); | ||
} | ||
} | ||
|
||
&:last-child { | ||
margin-right: 0; | ||
&--isBlock { | ||
flex-grow: 1; | ||
} | ||
|
||
&--isActive { | ||
background-color: var(--color-background); | ||
color: var(--color-foreground); | ||
margin-bottom: -1px; | ||
&--disabled { | ||
cursor: not-allowed; | ||
color: var(--color-muted); | ||
|
||
&:hover { | ||
border-color: var(--color-neutral); | ||
border-bottom: 4px solid transparent; | ||
color: var(--color-muted); | ||
} | ||
} | ||
} |
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,52 @@ | ||
import * as React from 'react'; | ||
import bem from '../../../utils/bem'; | ||
import styles from './TabItem.scss'; | ||
|
||
export interface Props extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> { | ||
/** Id of this tab */ | ||
tabId: string | number; | ||
/** Renders an active tab. This prop will be set by TabsBar if activeTabId is defined there */ | ||
isActive?: boolean; | ||
/** Disabled tab item */ | ||
disabled?: boolean; | ||
/** A callback when the tab is clicked. It will not be called for active or disabled tabs. This prop will be set by TabsBar if onSelect is defined there */ | ||
onSelect?: (tabId: string | number) => void; | ||
/** Label of the tab. Expected to be a string like node. E.g. `label` or `label <span>(3)</span>` */ | ||
children: ReactNode; | ||
/** used for styling when TabsBar is full width. Will be set by TabsBar, no need to set manually */ | ||
isBlock?: boolean; | ||
} | ||
|
||
const { block } = bem('TabItem', styles); | ||
|
||
const TabItem: React.FC<Props> = props => { | ||
const { tabId, isActive, onSelect, disabled, isBlock, children, ...rest } = props; | ||
const handleClick = () => { | ||
if (!isActive && !disabled && onSelect) { | ||
onSelect(tabId); | ||
} | ||
}; | ||
|
||
return ( | ||
<div | ||
tabIndex={0} | ||
{...rest} | ||
{...block(props)} | ||
role="tab" | ||
aria-selected={isActive} | ||
onClick={handleClick} | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
TabItem.displayName = 'TabItem'; | ||
|
||
TabItem.defaultProps = { | ||
isActive: false, | ||
isBlock: false, | ||
disabled: false, | ||
}; | ||
|
||
export default TabItem; |
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
47 changes: 21 additions & 26 deletions
47
src/components/Tabs/TabItem/__tests__/__snapshots__/TabItem.spec.js.snap
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 |
---|---|---|
@@ -1,39 +1,34 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<TabItem> should add classes for props 1`] = ` | ||
<a | ||
aria-selected={true} | ||
className="TabItem TabItem--isActive" | ||
href="#" | ||
role="tab" | ||
tabIndex={0} | ||
> | ||
Some tab | ||
</a> | ||
`; | ||
exports[`<TabItem> should allow node type labels 1`] = ` | ||
<a | ||
exports[`<TabItem> should render a tab item correctly with minimum props 1`] = ` | ||
<div | ||
aria-selected={false} | ||
className="TabItem" | ||
href="#" | ||
onClick={[Function]} | ||
role="tab" | ||
tabIndex={0} | ||
> | ||
<strong> | ||
Some tab | ||
</strong> | ||
</a> | ||
Tab label | ||
</div> | ||
`; | ||
exports[`<TabItem> should render a tab item correctly 1`] = ` | ||
<a | ||
aria-selected={false} | ||
className="TabItem" | ||
href="#" | ||
exports[`<TabItem> should render correctly with all props 1`] = ` | ||
<div | ||
aria-selected={true} | ||
className="TabItem TabItem--isActive TabItem--isBlock" | ||
onClick={[Function]} | ||
role="tab" | ||
tabIndex={0} | ||
> | ||
Some tab | ||
</a> | ||
Tab label | ||
<span | ||
style={ | ||
Object { | ||
"color": "grey", | ||
} | ||
} | ||
> | ||
(3) | ||
</span> | ||
</div> | ||
`; |
Oops, something went wrong.