Skip to content

Commit 70eaf6c

Browse files
committed
Expose wrapper styles
1 parent f3b5265 commit 70eaf6c

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

packages/gitbook/src/components/DocumentView/HashLinkButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import { getBlockTextStyle } from './spacing';
55

66
/**
77
* A hash icon which adds the block or active block item's ID in the URL hash.
8+
* The button needs to be wrapped in a container with `hashLinkButtonWrapperStyles`.
89
*/
10+
export const hashLinkButtonWrapperStyles = tcls('relative', 'group');
11+
912
export function HashLinkButton(props: {
1013
id: string;
1114
block: DocumentBlockTabs | DocumentBlockHeading;
@@ -20,9 +23,6 @@ export function HashLinkButton(props: {
2023
'hash',
2124
'grid',
2225
'grid-area-1-1',
23-
// 'absolute',
24-
// 'left-0',
25-
// 'top-1',
2626
'w-7',
2727
'border-0',
2828
'opacity-0',

packages/gitbook/src/components/DocumentView/Heading.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { DocumentBlockHeading } from '@gitbook/api';
33
import { tcls } from '@/lib/tailwind';
44

55
import type { BlockProps } from './Block';
6-
import { HashLinkButton } from './HashLinkButton';
6+
import { HashLinkButton, hashLinkButtonWrapperStyles } from './HashLinkButton';
77
import { Inlines } from './Inlines';
88
import { getBlockTextStyle } from './spacing';
99

@@ -23,10 +23,9 @@ export function Heading(props: BlockProps<DocumentBlockHeading>) {
2323
className={tcls(
2424
textStyle.textSize,
2525
'heading',
26-
'group',
27-
'relative',
2826
'grid',
2927
'scroll-m-12',
28+
hashLinkButtonWrapperStyles,
3029
style
3130
)}
3231
>

packages/gitbook/src/components/DocumentView/Tabs/DynamicTabs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useHash, useIsMounted } from '@/components/hooks';
66
import * as storage from '@/lib/local-storage';
77
import { type ClassValue, tcls } from '@/lib/tailwind';
88
import type { DocumentBlockTabs } from '@gitbook/api';
9-
import { HashLinkButton } from '../HashLinkButton';
9+
import { HashLinkButton, hashLinkButtonWrapperStyles } from '../HashLinkButton';
1010

1111
interface TabsState {
1212
activeIds: {
@@ -141,7 +141,7 @@ export function DynamicTabs(
141141
}, [hash, tabs, onSelectTab]);
142142

143143
return (
144-
<div className={tcls('relative', 'group')}>
144+
<div className={hashLinkButtonWrapperStyles}>
145145
<HashLinkButton
146146
id={getTabButtonId(active.id)}
147147
block={block}

0 commit comments

Comments
 (0)