Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {XIcon} from '@primer/octicons-react'
import classes from './AnchoredOverlay.module.css'
import {clsx} from 'clsx'
import {useFeatureFlag} from '../FeatureFlags'
import {widthMap} from '../Overlay/Overlay'
import {widthMap} from '../Overlay/constants'

interface AnchoredOverlayPropsWithAnchor {
/**
Expand Down
18 changes: 1 addition & 17 deletions packages/react/src/KeybindingHint/KeybindingHint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import {type ReactNode} from 'react'
import {memo} from 'react'
import Text from '../Text'
import type {KeybindingHintProps} from './props'
import {accessibleSequenceString, Sequence} from './components/Sequence'
import type {Platform} from './platform'
import {Sequence} from './components/Sequence'

import classes from './KeybindingHint.module.css'
import {clsx} from 'clsx'
Expand All @@ -30,18 +29,3 @@ export const KeybindingHint = memo(({className, ...props}: KeybindingHintProps)
</Kbd>
))
KeybindingHint.displayName = 'KeybindingHint'

/**
* AVOID: `KeybindingHint` is nearly always sufficient for providing both visible and accessible keyboard hints.
* However, there may be cases where we need a plain string version, such as when building `aria-label` or
* `aria-description`. In that case, this plain string builder can be used instead.
*
* NOTE that this string should _only_ be used when building `aria-label` or `aria-description` props (never rendered
* visibly) and should nearly always also be paired with a visible hint for sighted users.
*
* The `platform` argument controls how platform-specific keys (such as `Meta`, `Alt`, and `Mod`) are named. For
* backwards compatibility, a `boolean` may be passed instead, where `true` is treated as `'apple'` and `false` as
* `'other'`.
*/
export const getAccessibleKeybindingHintString = (sequence: string, platform: Platform | boolean) =>
accessibleSequenceString(sequence, typeof platform === 'boolean' ? (platform ? 'apple' : 'other') : platform)
4 changes: 1 addition & 3 deletions packages/react/src/KeybindingHint/components/Chord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {KeybindingHintProps} from '../props'
import {Key} from './Key'
import {clsx} from 'clsx'
import classes from './Chord.module.css'
import {accessibleChordString, splitChord} from './utils'
import {splitChord} from './utils'

export const Chord = ({keys, format = 'condensed', variant = 'normal', size = 'normal'}: KeybindingHintProps) => (
<Text
Expand All @@ -29,5 +29,3 @@ export const Chord = ({keys, format = 'condensed', variant = 'normal', size = 'n
))}
</Text>
)

export {accessibleChordString}
3 changes: 0 additions & 3 deletions packages/react/src/KeybindingHint/components/Sequence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Fragment} from 'react'
import type {KeybindingHintProps} from '../props'
import VisuallyHidden from '../../_VisuallyHidden'
import {Chord} from './Chord'
import {accessibleSequenceString} from './utils'

const splitSequence = (sequence: string) => sequence.split(' ')

Expand All @@ -20,5 +19,3 @@ export const Sequence = ({keys, ...chordProps}: KeybindingHintProps) =>
<Chord keys={c} {...chordProps} />
</Fragment>
))

export {accessibleSequenceString}
3 changes: 2 additions & 1 deletion packages/react/src/KeybindingHint/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './KeybindingHint'
export {KeybindingHint} from './KeybindingHint'
export {getAccessibleKeybindingHintString} from './utils'

export type {KeybindingHintProps} from './props'
17 changes: 17 additions & 0 deletions packages/react/src/KeybindingHint/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {accessibleSequenceString} from './components/utils'
import type {Platform} from './platform'

/**
* AVOID: `KeybindingHint` is nearly always sufficient for providing both visible and accessible keyboard hints.
* However, there may be cases where we need a plain string version, such as when building `aria-label` or
* `aria-description`. In that case, this plain string builder can be used instead.
*
* NOTE that this string should _only_ be used when building `aria-label` or `aria-description` props (never rendered
* visibly) and should nearly always also be paired with a visible hint for sighted users.
*
* The `platform` argument controls how platform-specific keys (such as `Meta`, `Alt`, and `Mod`) are named. For
* backwards compatibility, a `boolean` may be passed instead, where `true` is treated as `'apple'` and `false` is
* treated as `'other'`.
*/
export const getAccessibleKeybindingHintString = (sequence: string, platform: Platform | boolean) =>
accessibleSequenceString(sequence, typeof platform === 'boolean' ? (platform ? 'apple' : 'other') : platform)
3 changes: 1 addition & 2 deletions packages/react/src/Overlay/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../uti
import classes from './Overlay.module.css'
import {clsx} from 'clsx'
import {useFeatureFlag} from '../FeatureFlags'
import {heightMap, widthMap} from './constants'
import type {heightMap, widthMap} from './constants'

type StyledOverlayProps = {
width?: keyof typeof widthMap
Expand All @@ -22,7 +22,6 @@ type StyledOverlayProps = {
style?: React.CSSProperties
}

export {heightMap, widthMap}
const animationDuration = 200

function getSlideAnimationStartingVector(anchorSide?: AnchorSide): {x: number; y: number} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import {render as HTMLRender, fireEvent, act, render} from '@testing-library/react'
import {describe, expect, it, vi, beforeEach, afterEach} from 'vitest'
import type {TokenSizeKeys} from '../Token/TokenBase'
import {tokenSizes} from '../Token/TokenBase'
import {tokenSizes} from '../Token/constants'
import {IssueLabelToken} from '../Token'
import type {TextInputWithTokensProps} from '../TextInputWithTokens'
import TextInputWithTokens from '../TextInputWithTokens'
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/Timeline/Timeline.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type {Meta, StoryFn} from '@storybook/react-vite'
import React from 'react'
import {useArgs} from 'storybook/preview-api'
import type {ComponentProps} from '../utils/types'
import Timeline, {TimelineBadgeVariants, type TimelineBadgeVariant} from './Timeline'
import Timeline, {type TimelineBadgeVariant} from './Timeline'
import {TimelineBadgeVariants} from './constants'
import Avatar from '../Avatar'
import {Button} from '../Button'
import Link from '../Link'
Expand Down
4 changes: 1 addition & 3 deletions packages/react/src/Timeline/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {clsx} from 'clsx'
import React from 'react'
import {useFeatureFlag} from '../FeatureFlags'
import classes from './Timeline.module.css'
import {TimelineBadgeVariants} from './constants'
import type {TimelineBadgeVariants} from './constants'

type StyledTimelineProps = {clipSidebar?: boolean | 'start' | 'end' | 'both'; className?: string}

Expand Down Expand Up @@ -84,8 +84,6 @@ const TimelineItem = React.forwardRef<HTMLDivElement | HTMLLIElement, TimelineIt

TimelineItem.displayName = 'TimelineItem'

export {TimelineBadgeVariants}

export type TimelineBadgeVariant = (typeof TimelineBadgeVariants)[number]

export type TimelineBadgeProps = {
Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/Token/IssueLabelToken.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type {MouseEventHandler} from 'react'
import {forwardRef, useMemo} from 'react'
import type {TokenBaseProps} from './TokenBase'
import TokenBase, {defaultTokenSize, isTokenInteractive} from './TokenBase'
import TokenBase from './TokenBase'
import {defaultTokenSize} from './constants'
import {isTokenInteractive} from './utils'
import RemoveTokenButton from './_RemoveTokenButton'
import {parseToHsla, parseToRgba} from 'color2k'
import TokenTextContainer from './_TokenTextContainer'
Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/Token/Token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import type {MouseEventHandler} from 'react'
import type React from 'react'
import {forwardRef} from 'react'
import type {TokenBaseProps} from './TokenBase'
import TokenBase, {defaultTokenSize, isTokenInteractive} from './TokenBase'
import TokenBase from './TokenBase'
import {defaultTokenSize} from './constants'
import {isTokenInteractive} from './utils'
import RemoveTokenButton from './_RemoveTokenButton'
import TokenTextContainer from './_TokenTextContainer'
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/Token/TokenBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import React from 'react'
import {clsx} from 'clsx'
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
import classes from './TokenBase.module.css'
import {defaultTokenSize, type TokenSizeKeys, tokenSizes} from './constants'
import {defaultTokenSize, type TokenSizeKeys} from './constants'
import {isTokenInteractive} from './utils'

export {defaultTokenSize, isTokenInteractive, tokenSizes}
export type {TokenSizeKeys}

export interface TokenBaseProps
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/Token/_RemoveTokenButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type React from 'react'
import {XIcon} from '@primer/octicons-react'
import {clsx} from 'clsx'
import type {TokenSizeKeys} from './TokenBase'
import {defaultTokenSize} from './TokenBase'
import {defaultTokenSize} from './constants'

import classes from './_RemoveTokenButton.module.css'

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/Token/__tests__/Token.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event'
import type React from 'react'
import Token from '../Token'
import type {TokenSizeKeys} from '../TokenBase'
import {tokenSizes} from '../TokenBase'
import {tokenSizes} from '../constants'
import {IssueLabelToken} from '..'
import {implementsClassName} from '../../utils/testing'
import classes from '../Token.module.css'
Expand Down
2 changes: 0 additions & 2 deletions packages/react/src/UnderlineNav/UnderlineNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ const overflowEffect = (
updateListAndMenu({items, menuItems}, iconsVisible, true)
}

export {getValidChildren}

const calculatePossibleItems = (childWidthArray: ChildWidthArray, navWidth: number, moreMenuWidth = 0) => {
const widthToFit = navWidth - moreMenuWidth
let breakpoint = childWidthArray.length // assume all items will fit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {ActionListContainerContext} from '../../ActionList/ActionListContainerCo
import {useSlots} from '../../hooks/useSlots'
import {useProvidedRefOrCreate, useId, useAnchoredPosition} from '../../hooks'
import type {OverlayProps} from '../../Overlay/Overlay'
import {BaseOverlay, heightMap} from '../../Overlay/Overlay'
import {BaseOverlay} from '../../Overlay/Overlay'
import {heightMap} from '../../Overlay/constants'
import {InputLabel} from '../../internal/components/InputLabel'
import {invariant} from '../../utils/invariant'
import {AriaStatus} from '../../live-region'
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/experimental/SelectPanel2/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './SelectPanel'
export {SelectPanel} from './SelectPanel'
export type {SelectPanelMessageProps, SelectPanelProps, SelectPanelSecondaryActionProps} from './SelectPanel'
Loading