Skip to content

Commit

Permalink
Add and export class names (#2335)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephl3 authored May 9, 2024
1 parent 3364b54 commit 918b4e6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/tabs/src/Tabs/Tabs.styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { css } from '@leafygreen-ui/emotion';
import { Theme } from '@leafygreen-ui/lib';
import { createUniqueClassName, Theme } from '@leafygreen-ui/lib';
import { palette } from '@leafygreen-ui/palette';

export const tabListElementClassName = createUniqueClassName('tab-list');
export const tabPanelsElementClassName = createUniqueClassName('tab-panels');

// Using a background allows the "border" to appear underneath the individual tab color
export const modeColors = {
[Theme.Light]: {
Expand Down
10 changes: 8 additions & 2 deletions packages/tabs/src/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
listStyle,
modeColors,
tabContainerStyle,
tabListElementClassName,
tabPanelsElementClassName,
} from './Tabs.styles';
import { AccessibleTabsProps } from './Tabs.types';

Expand Down Expand Up @@ -163,7 +165,11 @@ function Tabs(props: AccessibleTabsProps) {
<div className={tabContainerStyle}>
{/* renderedTabs portals the tab title into this element */}
<div
className={cx(listStyle, modeColors[theme].underlineColor)}
className={cx(
listStyle,
modeColors[theme].underlineColor,
tabListElementClassName,
)}
role="tablist"
ref={setTabNode}
aria-orientation="horizontal"
Expand All @@ -175,7 +181,7 @@ function Tabs(props: AccessibleTabsProps) {
</div>

{/* renderedTabs portals the contents into this element */}
<div ref={setPanelNode} />
<div className={tabPanelsElementClassName} ref={setPanelNode} />
</div>
</LeafyGreenProvider>
);
Expand Down
4 changes: 4 additions & 0 deletions packages/tabs/src/Tabs/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
export { default } from './Tabs';
export {
tabListElementClassName,
tabPanelsElementClassName,
} from './Tabs.styles';
export type { AccessibleTabsProps, TabsProps } from './Tabs.types';
6 changes: 5 additions & 1 deletion packages/tabs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export type { TabProps } from './Tab';
export { default as Tab } from './Tab';
export type { AccessibleTabsProps as TabsProps } from './Tabs';
export { default as Tabs } from './Tabs';
export {
tabListElementClassName,
tabPanelsElementClassName,
default as Tabs,
} from './Tabs';

0 comments on commit 918b4e6

Please sign in to comment.