Skip to content

Commit

Permalink
fix lint problems
Browse files Browse the repository at this point in the history
  • Loading branch information
talentlessguy committed Aug 7, 2024
1 parent 89c9ad8 commit 5222a0e
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const transitionStateValues: {
},
}

type Property = keyof typeof transitionStateValues['unmounted']
type Property = keyof (typeof transitionStateValues)['unmounted']

export const getValueForTransitionState = (
state: TransitionState['status'],
Expand Down
122 changes: 61 additions & 61 deletions components/src/components/atoms/RecordItem/RecordItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,68 +190,68 @@ export const RecordItem = React.forwardRef<
const hasPrefix = !!icon || !!keyLabel
const hasLabels = !!keyLabel || !!keySublabel

const KeyLabel =
typeof keyLabel === 'string' ? (
<Typography
color="grey"
ellipsis={!inline}
fontVariant={size === 'large' ? 'bodyBold' : 'smallBold'}
textAlign="left"
width="$full"
>
{keyLabel}
</Typography>
) : (
keyLabel
)

const KeySublabel =
typeof keySublabel === 'string' ? (
<Typography
color="grey"
ellipsis={!inline}
fontVariant={size === 'large' ? 'smallBold' : 'extraSmallBold'}
textAlign="left"
width="$full"
>
{keySublabel}
</Typography>
) : (
keySublabel
)
const PostfixProps = postfixIcon
? { as: postfixIcon }
: link
? { $rotate: true, as: UpArrowSVG }
: copied
? { as: CheckSVG }
: { as: CopySVG }
const KeyLabel =
typeof keyLabel === 'string' ? (
<Typography
color="grey"
ellipsis={!inline}
fontVariant={size === 'large' ? 'bodyBold' : 'smallBold'}
textAlign="left"
width="$full"
>
{keyLabel}
</Typography>
) : (
keyLabel
)

return (
<ContainerBox $inline={inline} as={asProp} {...generatedProps}>
{hasPrefix && (
<PrefixBox $inline={inline} $size={size}>
{icon && <PrefixSVGBox as={icon as React.ReactElement} />}
{hasLabels && (
<PrefixLabelsContainerBox $inline={inline}>
{KeyLabel}
{KeySublabel}
</PrefixLabelsContainerBox>
)}
</PrefixBox>
)}
<Typography
flex="1"
fontVariant={size === 'large' ? 'body' : 'small'}
textAlign="left"
wordBreak={inline ? 'normal' : 'break-all'}
>
{children}
</Typography>
<TrailingSVGBox {...(PostfixProps as any)} />
</ContainerBox>
)
})
const KeySublabel =
typeof keySublabel === 'string' ? (
<Typography
color="grey"
ellipsis={!inline}
fontVariant={size === 'large' ? 'smallBold' : 'extraSmallBold'}
textAlign="left"
width="$full"
>
{keySublabel}
</Typography>
) : (
keySublabel
)
const PostfixProps = postfixIcon
? { as: postfixIcon }
: link
? { $rotate: true, as: UpArrowSVG }
: copied
? { as: CheckSVG }
: { as: CopySVG }

return (
<ContainerBox $inline={inline} as={asProp} {...generatedProps}>
{hasPrefix && (
<PrefixBox $inline={inline} $size={size}>
{icon && <PrefixSVGBox as={icon as React.ReactElement} />}
{hasLabels && (
<PrefixLabelsContainerBox $inline={inline}>
{KeyLabel}
{KeySublabel}
</PrefixLabelsContainerBox>
)}
</PrefixBox>
)}
<Typography
flex="1"
fontVariant={size === 'large' ? 'body' : 'small'}
textAlign="left"
wordBreak={inline ? 'normal' : 'break-all'}
>
{children}
</Typography>
<TrailingSVGBox {...(PostfixProps as any)} />
</ContainerBox>
)
},
)

RecordItem.displayName = 'RecordItem'
96 changes: 61 additions & 35 deletions components/src/components/atoms/ScrollBox/ScrollBox.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import * as React from 'react'

import * as styles from './styles.css'
import { Box, BoxProps } from '../Box/Box'
import { commonVars } from '@/src/css/theme.css'

import { Space } from '@/src/tokens'

import * as styles from './styles.css'
import { Box, BoxProps } from '../Box/Box'

const ScrollBoxBox = React.forwardRef<HTMLElement, BoxProps>((props, ref) => (
<Box
ref={ref}
classNames={styles.scrollBox}
{...props}
/>
<Box classNames={styles.scrollBox} ref={ref} {...props} />
))

const DividerBox = ({
Expand All @@ -23,22 +21,28 @@ const DividerBox = ({
horizontalPadding?: Space
}) => {
return (
<Box
style={horizontalPadding ? { width: `calc(100% - 2 * ${commonVars.space[horizontalPadding]})`} : {}}
backgroundColor={show ? '$border' : 'transparent'}
bottom={position === 'bottom' ? '-$px' : 'unset'}
data-testid={`scrollbox-${position}-divider`}
display="block"
height="$px"
left={horizontalPadding ? commonVars.space[horizontalPadding] :"$0"}
position="absolute"
top={position === 'top' ? '$0' : 'unset'}
transitionDuration="$150"
transitionProperty="background-color"
transitionTimingFunction="$inOut"
width="$full"
zIndex="100"
/>)}
<Box
backgroundColor={show ? '$border' : 'transparent'}
bottom={position === 'bottom' ? '-$px' : 'unset'}
data-testid={`scrollbox-${position}-divider`}
display="block"
height="$px"
left={horizontalPadding ? commonVars.space[horizontalPadding] : '$0'}
position="absolute"
style={
horizontalPadding
? { width: `calc(100% - 2 * ${commonVars.space[horizontalPadding]})` }
: {}
}
top={position === 'top' ? '$0' : 'unset'}
transitionDuration="$150"
transitionProperty="background-color"
transitionTimingFunction="$inOut"
width="$full"
zIndex="100"
/>
)
}

type Props = {
/** If true, the dividers will be hidden */
Expand Down Expand Up @@ -143,27 +147,49 @@ export const ScrollBox = ({

return (
<Box
position="relative"
border="solid $px transparent"
width="$full"
height="$full"
borderLeftWidth="$0"
borderRightWidth="$0"
height="$full"
position="relative"
width="$full"
{...props}
>
<ScrollBoxBox style={horizontalPadding ? {
padding: `0 ${commonVars.space[horizontalPadding]}`,
} : {}}>
<Box data-testid="scrollbox-top-intersect" ref={topRef}
display="block" height="$0"
<ScrollBoxBox
style={
horizontalPadding
? {
padding: `0 ${commonVars.space[horizontalPadding]}`,
}
: {}
}
>
<Box
data-testid="scrollbox-top-intersect"
display="block"
height="$0"
ref={topRef}
/>
{children}
<Box data-testid="scrollbox-bottom-intersect" ref={bottomRef}
display="block" height="$0"
<Box
data-testid="scrollbox-bottom-intersect"
display="block"
height="$0"
ref={bottomRef}
/>
</ScrollBoxBox>
<DividerBox data-testid="scrollbox-top-line" show={showTop} position='top' horizontalPadding={horizontalPadding}/>
<DividerBox data-testid="scrollbox-bottom-line" show={showBottom} position='bottom' horizontalPadding={horizontalPadding}/>
<DividerBox
data-testid="scrollbox-top-line"
horizontalPadding={horizontalPadding}
position="top"
show={showTop}
/>
<DividerBox
data-testid="scrollbox-bottom-line"
horizontalPadding={horizontalPadding}
position="bottom"
show={showBottom}
/>
</Box>
)
}
4 changes: 2 additions & 2 deletions components/src/components/atoms/ScrollBox/styles.css.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { style, createVar } from '@vanilla-extract/css'
import { createVar, style } from '@vanilla-extract/css'

import { commonVars, modeVars } from '@/src/css/theme.css'

Expand All @@ -10,7 +10,7 @@ export const scrollBox = style({
syntax: '<color>',
inherits: false,
initialValue: modeVars.color.greyLight,
}
},
},
overflow: 'auto',
position: 'relative',
Expand Down
5 changes: 2 additions & 3 deletions components/src/components/organisms/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ const StyledCard = (props: BoxProps) => (
display="flex"
flexDirection="column"
gap={{ xs: '$4', sm: '$6' }}
maxWidth={{ xs: 'unset', sm: '80vw' }}
maxHeight={{ xs: '80vh', sm: 'min(90vh, $144)' }}
maxWidth={{ xs: 'unset', sm: '80vw' }}
minWidth={{ xs: 'unset', sm: '$64' }}
overflow="hidden"
padding={{ xs: '$4', sm: '$6' }}
position="relative"
overflow="hidden"
width="$full"
/>

)

type NonNullableAlert = NonNullable<WithAlert['alert']>
Expand Down
4 changes: 2 additions & 2 deletions components/src/components/organisms/Dialog/DialogContent.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react'
import styled, { css } from 'styled-components'

import { mq } from '@/src/utils/responsiveHelpers'

import { Space } from '@/src/tokens'

import { mq } from '@/src/utils/responsiveHelpers'

import { ScrollBox } from '../..'

type NativeFromProps = React.FormHTMLAttributes<HTMLFormElement>
Expand Down
4 changes: 2 additions & 2 deletions components/src/css/utils/getColorStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const BASE_COLORS = [
'grey',
] as const

type BaseColor = typeof BASE_COLORS[number]
type BaseColor = (typeof BASE_COLORS)[number]

const GRADIENT_COLORS = [
'accent',
Expand All @@ -23,7 +23,7 @@ const GRADIENT_COLORS = [
'grey',
] as const

type GradientColor = typeof GRADIENT_COLORS[number]
type GradientColor = (typeof GRADIENT_COLORS)[number]

const makeColorStyleMap = () => {
const primaryStyles = Object.fromEntries(
Expand Down
2 changes: 1 addition & 1 deletion components/src/tokens/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const gradients = {
*/

export type NamedShade = keyof typeof namedShadeMap
export type Shade = typeof shades[number]
export type Shade = (typeof shades)[number]
export type Hue = keyof typeof hues
export type Category = keyof Categories | 'accent'
export type Gradient = keyof typeof gradients
Expand Down
2 changes: 1 addition & 1 deletion components/src/tokens/colors2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const gradients = {
*/

export type NamedShade = keyof typeof namedShadeMap
export type Shade = typeof shades[number]
export type Shade = (typeof shades)[number]
export type Hue = keyof typeof hues
export type Category = keyof Categories | 'accent'
export type Gradient = keyof typeof gradients
Expand Down
2 changes: 1 addition & 1 deletion components/src/types/withColorOrColorStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const BASE_COLORS = [
'grey',
] as const

type BaseColor = typeof BASE_COLORS[number]
type BaseColor = (typeof BASE_COLORS)[number]

type ColorStyleItem = {
text: string
Expand Down

0 comments on commit 5222a0e

Please sign in to comment.