Skip to content

Commit

Permalink
feat: update scrollbar (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsladerman authored Aug 20, 2024
1 parent 21a0470 commit d1821aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/components/Flex.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// drop-in replacement for anywhere 'honorable' Flex is used. Moving forward a regular div or a styled component should just be used instead
// drop-in replacement for anywhere 'honorable' Flex is used

import {
type CSSProperties,
type ComponentProps,
type ReactNode,
type Ref,
forwardRef,
memo,
Expand Down Expand Up @@ -46,9 +46,11 @@ type FlexBaseProps = {
| 'space-evenly'

gap?: string

children?: ReactNode
}

type FlexProps = CSSProperties & ComponentProps<'div'> & FlexBaseProps
type FlexProps = Omit<CSSProperties, keyof FlexBaseProps> & FlexBaseProps

function FlexRef(props: FlexProps, ref: Ref<any>) {
const {
Expand Down
16 changes: 12 additions & 4 deletions src/components/IconFrame.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { ButtonBase, Flex } from 'honorable'
import {
type ComponentProps,
type ReactElement,
type ReactNode,
cloneElement,
forwardRef,
} from 'react'
import { ButtonBase, Flex, type FlexProps } from 'honorable'
import styled from 'styled-components'

import { type styledTheme } from '../theme'

import { type SemanticColorKey } from '../theme/colors'

import Tooltip, { type TooltipProps } from './Tooltip'

type Size = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge'
Expand Down Expand Up @@ -85,7 +87,7 @@ const sizeToFrameSize: Record<Size, number> = {
xlarge: 48,
}

type IconFrameProps = Omit<FlexProps, 'size'> & {
type IconFrameProps = {
clickable?: boolean
disabled?: boolean
textValue?: string
Expand All @@ -95,21 +97,25 @@ type IconFrameProps = Omit<FlexProps, 'size'> & {
tooltipProps?: Partial<TooltipProps>
type?: Type
selected?: boolean
background?: SemanticColorKey
}

const IconFrameSC = styled(Flex)<{
$type: Type
$clickable: boolean
$selected: boolean
$size: Size
}>(({ theme, $type, $clickable, $selected, $size }) => ({
$background?: SemanticColorKey
}>(({ theme, $type, $clickable, $selected, $size, $background }) => ({
display: 'flex',
alignItems: 'center',
alignContent: 'center',
justifyContent: 'center',
width: sizeToFrameSize[$size],
height: sizeToFrameSize[$size],
backgroundColor: $selected
backgroundColor: $background
? theme.colors[$background]
: $selected
? typeToSelectedBG(theme)[$type]
: typeToBG(theme)[$type],
border: typeToBorder(theme)[$type],
Expand Down Expand Up @@ -157,6 +163,7 @@ const IconFrame = forwardRef<
tooltip,
tooltipProps,
type = 'tertiary',
background,
as,
...props
},
Expand All @@ -174,6 +181,7 @@ const IconFrame = forwardRef<
$selected={selected}
$type={type}
$size={size}
$background={background}
ref={ref}
aria-label={textValue}
disabled={(clickable && disabled) || undefined}
Expand Down
7 changes: 2 additions & 5 deletions src/theme/scrollBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ import { type FillLevel } from '../components/contexts/FillLevelContext'
import { semanticColorCssVars } from './colors'

export const scrollBar = ({ fillLevel }: { fillLevel: FillLevel }) => {
const trackColor =
fillLevel >= 2
? semanticColorCssVars['fill-three']
: semanticColorCssVars['fill-two']
const trackColor = 'transparent'
const barColor =
fillLevel >= 2
? semanticColorCssVars['text-xlight']
: semanticColorCssVars['fill-three']
: semanticColorCssVars['fill-three-hover']
const barWidth = 6
const barRadius = barWidth / 2

Expand Down

0 comments on commit d1821aa

Please sign in to comment.