Skip to content

Commit

Permalink
added a variable count width to tabs
Browse files Browse the repository at this point in the history
we may want to add this to badge instead,
but badge has a variable width by default.
the fixed width badge was only the spec of tabs' counts.
  • Loading branch information
miloofcroton committed May 9, 2019
1 parent 374abfc commit 4a4c0c8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
- added `isInvisible` to `SingleSelect`. We do not use a button under the hood for this component, but this simulates an invisible `Button`, styling-wise.
- removed `kindOf` from `ToolTip`
- added `isLight` to `ToolTip`. The default now has dark styling, and this adds light styling.
- added `isVariableCountWidth` to `Tabs`. Allows count badges to have fixed or variable widths.
13 changes: 10 additions & 3 deletions src/components/Tabs/Tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ const Tab = createClass({
count: number`
Optional prop that will show a count number next to the tab's title.
`,

isVariableCountWidth: bool`
Defaults to false.
Allows the count bubble to grow large. Useful if working with huge numbers.
`,
},

handleClick(event) {
Expand All @@ -95,6 +100,7 @@ const Tab = createClass({
Title,
className,
count,
isVariableCountWidth,
...passThroughs
} = this.props;

Expand All @@ -119,7 +125,8 @@ const Tab = createClass({
<Badge
style={{
marginLeft: '12px',
width: '20px',
width: isVariableCountWidth ? null : '20px',
minWidth: '20px',
}}
type="stroke"
kind={isSelected ? 'primary' : null}
Expand Down Expand Up @@ -219,7 +226,7 @@ const Tabs = createClass({
`,

isFloating: bool`
Provides a small bottom border that offers a barrier between the tab
Provides a small bottom border that offers a barrier between the tab
group and the rest of the page.
Useful if the tabs are not anchored to anything.
`,
Expand All @@ -237,7 +244,7 @@ const Tabs = createClass({

Tab: any`
*Child Element* Can be used to define one or more individual \`Tab\`s in
the sequence of \`Tabs\`.
the sequence of \`Tabs\`.
`,
},

Expand Down
21 changes: 21 additions & 0 deletions src/components/Tabs/examples/09-with-count.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default createClass({
render() {
return (
<div>
<h4>Static Width</h4>
<Tabs hasFullWidthTabs={false}>
<Tabs.Tab count={12}>
<Tabs.Title>One</Tabs.Title>
Expand All @@ -24,6 +25,26 @@ export default createClass({
Three content
</Tabs.Tab>
</Tabs>

<h4>Variable Width</h4>
<Tabs hasFullWidthTabs={false}>
<Tabs.Tab count={1231321} isVariableCountWidth={true}>
<Tabs.Title>One</Tabs.Title>
One content
</Tabs.Tab>
<Tabs.Tab count={6546541612} isVariableCountWidth={true}>
<Tabs.Title>Two</Tabs.Title>
Two content
</Tabs.Tab>
<Tabs.Tab count={7} isVariableCountWidth={true}>
<Tabs.Title>Three</Tabs.Title>
Three content
</Tabs.Tab>
<Tabs.Tab count={123} isDisabled isVariableCountWidth={true}>
<Tabs.Title>Three</Tabs.Title>
Three content
</Tabs.Tab>
</Tabs>
</div>
);
},
Expand Down

0 comments on commit 4a4c0c8

Please sign in to comment.