Skip to content

Commit ad3ae5b

Browse files
thinkclayclaude
andcommitted
feat(tabs): folder tabs take the prototype's index-card shape
The folder tab was a bordered rounded-top button in the body face. The SCF prototype's tab is an index card: the heading face at body size, medium weight, `padding: 8px 26px`, leaning back very slightly (perspective 12px, 1.4° about its bottom edge), the selected one lifted off the strip with a short upward shadow and the rest sitting a step behind with an inset shadow at the foot. The shape is now a layer behind the label (`TabStyleConfig.backdrop`, rendered by TabTrigger), so the label stays flat while the card leans. The strip's gap tightens to 2px to match. The selected label is accent-700 on the light panel and the ramp's light step on the dark ground, where accent-700 is near-invisible. The shadows are web-only — inset has no native form and the lift is too subtle to matter there. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 5b1ff92 commit ad3ae5b

4 files changed

Lines changed: 72 additions & 17 deletions

File tree

‎src/components/Tabs/TabTrigger.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Clickable tab button
44
*/
55

6-
import { View, Pressable, Text } from 'react-native'
6+
import { View, Pressable, StyleSheet, Text } from 'react-native'
77
import type { TabTriggerProps } from './Tabs.types'
88
import { useTabsContext } from './TabsContext'
99
import { useTabItemContext } from './TabItem'
@@ -52,6 +52,10 @@ export function TabTrigger({
5252
]}
5353
{...pressableProps}
5454
>
55+
{styles.backdrop ? (
56+
<View pointerEvents="none" style={[StyleSheet.absoluteFill, styles.backdrop]} />
57+
) : null}
58+
5559
{/* Icon Start */}
5660
{IconStart && (
5761
<View style={{ width: iconSize, height: iconSize }}>

‎src/components/Tabs/Tabs.styles.ts‎

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
* All styles mapped from Figma Forsured Design System
44
*/
55

6+
import { Platform } from 'react-native'
67
import type { ViewStyle, TextStyle } from 'react-native'
78
import { colors } from '../../tokens/colors'
89
import type { ResolvedThemeMode } from '../../tokens/colors'
910
import { borderRadius } from '../../tokens/borders'
1011
import { spacing } from '../../tokens/spacing'
11-
import { typography } from '../../tokens/typography'
12+
import { fontWeight, typography } from '../../tokens/typography'
1213
import { boxShadows } from '../../tokens/shadows'
1314
import type { TabType, TabColor, TabSize, TabOrientation, TabStyleConfig } from './Tabs.types'
1415

@@ -79,7 +80,7 @@ export function getTabListStyles(
7980
options?: { gap?: number; wrap?: boolean; type?: TabType }
8081
): ViewStyle {
8182
const folder = options?.type === 'folder' && orientation === 'horizontal'
82-
const gap = options?.gap ?? (orientation === 'horizontal' ? (folder ? spacing[4] : spacing[8]) : 0)
83+
const gap = options?.gap ?? (orientation === 'horizontal' ? (folder ? spacing[2] : spacing[8]) : 0)
8384
return {
8485
flexDirection: orientation === 'horizontal' ? 'row' : 'column',
8586
alignItems: orientation === 'horizontal' ? (folder ? 'flex-end' : 'flex-start') : 'stretch',
@@ -174,6 +175,7 @@ export function getTabTriggerStyles(
174175
let borderRightWidth: number | undefined
175176
let borderRightColor: string | undefined
176177
let boxShadow: string | undefined
178+
let backdrop: ViewStyle | undefined
177179

178180
// Determine colors based on state
179181
if (isDisabled) {
@@ -258,22 +260,54 @@ export function getTabTriggerStyles(
258260
backgroundColor = colors.bg[theme].subtle
259261
}
260262
} else if (type === 'folder') {
261-
// Folder type: a bordered tab with rounded top corners. The strip draws
262-
// the hairline (see getTabListStyles); the selected tab overlaps it by one
263-
// pixel and paints its own bottom edge in the surface colour, so the tab
264-
// and the panel below read as one shape. Unselected tabs sit on the
265-
// subtle ground a step back.
266-
container.borderWidth = 1
267-
container.borderColor = colors.border[theme].default
268-
container.borderTopLeftRadius = borderRadius.l
269-
container.borderTopRightRadius = borderRadius.l
263+
// Folder type — the SCF prototype's tab: a bordered shape with rounded
264+
// top corners, leaning back very slightly (perspective 12px, 1.4° about
265+
// its bottom edge) so the row reads as index-card tabs rather than
266+
// buttons. The shape is a layer behind the label (`backdrop`), so the
267+
// label stays flat; the strip draws the hairline (see getTabListStyles),
268+
// the selected tab overlaps it by a pixel and paints its own bottom edge
269+
// in the panel colour, so tab and panel read as one surface. Unselected
270+
// tabs sit on the ground a step back, with an inset shadow at the foot on
271+
// web; hovering lifts one to the panel colour.
272+
//
273+
// Typography follows the prototype's folder tabs: the heading face at
274+
// body size, medium weight, accent when selected and the secondary text
275+
// colour otherwise.
276+
const selected = isSelected && !isDisabled
277+
container.paddingHorizontal = spacing[24]
278+
container.paddingVertical = spacing[8]
279+
container.height = undefined
280+
container.minHeight = undefined
270281
container.marginBottom = -1
271-
if (isSelected && !isDisabled) {
272-
backgroundColor = colors.bg[theme].default
273-
container.borderBottomColor = colors.bg[theme].default
274-
} else {
275-
backgroundColor = isHovered && !isDisabled ? colors.bg[theme].default : colors.bg[theme].subtle
282+
container.zIndex = selected ? 2 : 1
283+
text.fontFamily = typography.h5.fontFamily
284+
text.fontWeight = fontWeight.medium
285+
// Accent-700 on the light panel; on the dark ground the same step is
286+
// near-invisible, so the selected label takes the ramp's light step.
287+
textColor = isDisabled
288+
? colors.text[theme].disabled
289+
: selected
290+
? theme === 'dark'
291+
? colors.primary[300]
292+
: colors.primary[700]
293+
: colors.text[theme].secondary
294+
iconColor = textColor
295+
backdrop = {
296+
borderWidth: 1,
297+
borderColor: colors.border[theme].default,
298+
borderTopLeftRadius: borderRadius.l,
299+
borderTopRightRadius: borderRadius.l,
300+
borderBottomWidth: selected ? 1 : 0,
301+
borderBottomColor: colors.bg[theme].default,
302+
backgroundColor:
303+
selected || (isHovered && !isDisabled) ? colors.bg[theme].default : colors.bg[theme].subtle,
304+
transform: [{ perspective: 12 }, { rotateX: '1.4deg' }],
305+
transformOrigin: 'bottom',
306+
...(Platform.OS === 'web' && {
307+
boxShadow: selected ? boxShadows.folderTabSelected : boxShadows.folderTab,
308+
}),
276309
}
310+
backgroundColor = 'transparent'
277311
borderBottomWidth = undefined
278312
borderRightWidth = undefined
279313
} else if (type === 'shadow') {
@@ -318,6 +352,7 @@ export function getTabTriggerStyles(
318352
container,
319353
text,
320354
iconColor,
355+
...(backdrop && { backdrop }),
321356
}
322357
}
323358

‎src/components/Tabs/Tabs.types.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,12 @@ export interface TabStyleConfig {
365365
*/
366366
container: ViewStyle
367367

368+
/**
369+
* An absolutely-positioned layer drawn behind the label. The folder tab
370+
* draws its bordered, skewed shape here so the label itself stays flat.
371+
*/
372+
backdrop?: ViewStyle
373+
368374
/**
369375
* Text style for tab label
370376
*/

‎src/tokens/shadows.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,16 @@ export const boxShadows = {
238238
// Extra large shadow - shadow-xl
239239
xl: '0 20px 25px -5px rgba(22, 17, 13, 0.102)', // #16110d1a, spread: -5
240240

241+
/**
242+
* Folder tabs (the SCF prototype's). The selected tab lifts off the strip
243+
* with a short upward shadow; an unselected one carries an inset shadow at
244+
* its foot so it reads as sitting a step behind the panel. Web only — the
245+
* inset form has no native equivalent, and the lift is too subtle to matter
246+
* there.
247+
*/
248+
folderTabSelected: '0 -2px 6px rgba(32, 31, 29, 0.10)',
249+
folderTab: 'inset 0 -8px 10px -8px rgba(32, 31, 29, 0.14)',
250+
241251
// Extra extra large shadow - shadow-xxl
242252
xxl: '0 25px 50px -12px rgba(22, 17, 13, 0.251)', // #16110d40, spread: -12
243253

0 commit comments

Comments
 (0)