-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: Add extra to tabs #136
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -33,14 +33,14 @@ const tabListCSS = css` | |||||
--tab-hover-color: ${transparentize(0.2, theme.colors.arizeBlue)}; | ||||||
--tab-selected-border-color: ${theme.colors.arizeBlue}; | ||||||
|
||||||
button { | ||||||
button[role='tab'] { | ||||||
box-sizing: border-box; /* place the border inside */ | ||||||
background-color: inherit; | ||||||
border: none; | ||||||
outline: none; | ||||||
cursor: pointer; | ||||||
padding: 0 ${theme.spacing.padding16}px; | ||||||
height: 30px; | ||||||
min-height: 30px; | ||||||
transition: 0.3s; | ||||||
font-weight: bold; | ||||||
border-color: var(--tab-border-color); | ||||||
|
@@ -50,14 +50,14 @@ const tabListCSS = css` | |||||
gap: var(--ac-global-dimension-static-size-65); | ||||||
} | ||||||
|
||||||
button[data-is-hidden='true'] { | ||||||
button[role='tab'][data-is-hidden='true'] { | ||||||
display: none; | ||||||
} | ||||||
|
||||||
&[data-orientation='horizontal'] { | ||||||
flex-direction: row; | ||||||
border-bottom: 1px solid var(--tab-border-color); | ||||||
button { | ||||||
button[role='tab'] { | ||||||
border-bottom: 2px solid transparent; | ||||||
&:hover { | ||||||
border-color: var(--tab-hover-color); | ||||||
|
@@ -66,11 +66,17 @@ const tabListCSS = css` | |||||
border-color: var(--tab-selected-border-color); | ||||||
} | ||||||
} | ||||||
.ac-tabs__extra-content { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the extra wrap right? probably worth not naming it content. ui-components/src/field/FieldLabel.tsx Line 91 in 3153c3d
|
||||||
display: flex; | ||||||
align-items: center; | ||||||
justify-content: flex-end; | ||||||
flex-grow: 1; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this means the extra takes up the entire width on the right-hand side - I think it's probably worth just having the content aligned left and let it form it's own layout rather than forcing flex. |
||||||
} | ||||||
} | ||||||
&[data-orientation='vertical'] { | ||||||
flex-direction: column; | ||||||
border-right: 1px solid var(--tab-border-color); | ||||||
button { | ||||||
button[role='tab'] { | ||||||
border-right: 2px solid transparent; | ||||||
&:hover { | ||||||
border-color: var(--tab-hover-color); | ||||||
|
@@ -79,6 +85,12 @@ const tabListCSS = css` | |||||
border-color: var(--tab-selected-border-color); | ||||||
} | ||||||
} | ||||||
.ac-tabs__extra-content { | ||||||
display: flex; | ||||||
align-items: center; | ||||||
justify-content: center; | ||||||
flex-grow: 1; | ||||||
} | ||||||
} | ||||||
`; | ||||||
|
||||||
|
@@ -106,6 +118,7 @@ export type TabsProps = { | |||||
* @default horizontal | ||||||
*/ | ||||||
orientation?: Orientation; | ||||||
extra?: ReactNode; // Extra controls on the tablist | ||||||
}; | ||||||
|
||||||
/** | ||||||
|
@@ -116,6 +129,7 @@ export function Tabs({ | |||||
className, | ||||||
onChange, | ||||||
orientation = 'horizontal', | ||||||
extra, | ||||||
}: TabsProps) { | ||||||
const tabs = parseTabList(children); | ||||||
const [selectedIndex, setSelectedIndex] = useState<number>(0); | ||||||
|
@@ -154,6 +168,7 @@ export function Tabs({ | |||||
</button> | ||||||
); | ||||||
})} | ||||||
{extra && <div className="ac-tabs__extra-content">{extra}</div>} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</div> | ||||||
<div className="ac-tabs__pane-container"> | ||||||
{Children.map(children, (child, index) => { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be worth figuring out a way to keep a specificity of 1 here. Having a specificity higher makes customization a bit harder