Skip to content

[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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

mj12albert
Copy link
Member

@mj12albert mj12albert added core Infrastructure work going on behind the scenes component: tabs labels May 7, 2025
Copy link

pkg-pr-new bot commented May 7, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@base-ui-components/react@1881

commit: f5f06f5

Copy link

netlify bot commented May 7, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit f5f06f5
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/682319f6c275e8000889549f
😎 Deploy Preview https://deploy-preview-1881--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mj12albert mj12albert marked this pull request as ready for review May 7, 2025 10:34
@@ -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;
Copy link
Member

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) {
Copy link
Member

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> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export interface Props extends BaseUIComponentProps<'div', TabsRoot.State> {
export interface Props extends BaseUIComponentProps<'div', State> {

@mj12albert mj12albert force-pushed the tabs/use-render-element branch from 71d70d4 to 87c9d5a Compare May 7, 2025 12:53
@mj12albert mj12albert requested a review from michaldudak May 7, 2025 13:01
@mj12albert
Copy link
Member Author

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;
Copy link
Member

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.

Copy link
Member Author

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

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 9, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tabs core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants