-
-
Notifications
You must be signed in to change notification settings - Fork 122
[Tabs] Refactor to useRenderElement
#1881
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
base: master
Are you sure you want to change the base?
Conversation
mj12albert
commented
May 7, 2025
- I have followed (at least) the PR section of the contributing guide.
commit: |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -94,12 +203,12 @@ export const TabsIndicator = React.forwardRef(function TabIndicator( | |||
|
|||
export namespace TabsIndicator { | |||
export interface State extends TabsRoot.State { | |||
selectedTabPosition: ActiveTabPosition | null; | |||
selectedTabSize: ActiveTabSize | null; | |||
selectedTabPosition: TabPosition | null; |
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.
The TabPosition and TabSize types should be publicly exported as they can be used in a render function
import { TabsListContext } from './TabsListContext'; | ||
|
||
const EMPTY_ARRAY: number[] = []; | ||
|
||
function getInset(tab: HTMLElement, tabsList: HTMLElement) { |
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.
nit: could you move these helper functions below the component? This way, while reading the code we'll go from high to low level details.
@@ -104,7 +202,7 @@ export const TabsList = React.forwardRef(function TabsList( | |||
export namespace TabsList { | |||
export type State = TabsRoot.State; | |||
|
|||
export interface Props extends BaseUIComponentProps<'div', TabsList.State> { | |||
export interface Props extends BaseUIComponentProps<'div', TabsRoot.State> { |
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.
export interface Props extends BaseUIComponentProps<'div', TabsRoot.State> { | |
export interface Props extends BaseUIComponentProps<'div', State> { |
71d70d4
to
87c9d5a
Compare
Fixed the comments ~ @michaldudak |
export type TabActivationDirection = 'left' | 'right' | 'up' | 'down' | 'none'; | ||
export type TabValue = any | null; | ||
|
||
export namespace TabsRoot { | ||
export type State = { | ||
orientation: TabsOrientation; | ||
orientation: Orientation; |
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.
IMO we could re-export Orientation
in the TabsRoot
namespace, so types are colocated from devs' point of view.
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.
Makes sense, should types like TabValue
/TabActivationDirection
be namespaced under the root too then? (or the most suitable part) @michaldudak