Skip to content

Commit

Permalink
refactor(style): rename cssVarValue to cssVar
Browse files Browse the repository at this point in the history
  • Loading branch information
sungik-choi committed Dec 15, 2023
1 parent 0dacb8a commit fbd6669
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '~/src/features'
import {
cssUrl,
cssVarValue,
cssVar,
px,
} from '~/src/utils/style'

Expand Down Expand Up @@ -53,14 +53,14 @@ export const AlphaSmoothCornersBox = forwardRef<HTMLElement, AlphaSmoothCornersB
'--b-alpha-smooth-corners-box-shadow-offset-y': shadow?.offsetY,
'--b-alpha-smooth-corners-box-shadow-blur-radius': px(shadow?.blurRadius ?? 0),
'--b-alpha-smooth-corners-box-shadow-spread-radius': px(shadowSpreadRadius),
'--b-alpha-smooth-corners-box-shadow-color': cssVarValue(shadow?.color),
'--b-alpha-smooth-corners-box-shadow-color': cssVar(shadow?.color),
/**
* NOTE: Calculate in javascript because it cannot access calculated values via CSS calc() in the paint worklet.
* @see {@link ~/src/features/SmoothCorners/smoothCornersScript.ts}
*/
'--b-alpha-smooth-corners-box-padding': px(shadowSpreadRadius * 2),
'--b-alpha-smooth-corners-box-margin': px(margin ?? 0),
'--b-alpha-smooth-corners-box-background-color': cssVarValue(backgroundColor),
'--b-alpha-smooth-corners-box-background-color': cssVar(backgroundColor),
'--b-alpha-smooth-corners-box-background-image': cssUrl(backgroundImage),
}), [
styleProp,
Expand Down
4 changes: 2 additions & 2 deletions packages/bezier-react/src/components/Spinner/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { forwardRef } from 'react'

import classNames from 'classnames'

import { cssVarValue } from '~/src/utils/style'
import { cssVar } from '~/src/utils/style'

import type SpinnerProps from './Spinner.types'
import { SpinnerSize } from './Spinner.types'
Expand All @@ -27,7 +27,7 @@ const Spinner = forwardRef<HTMLDivElement, SpinnerProps>(function Spinner({
{...rest}
ref={forwardedRef}
style={{
'--b-spinner-color': cssVarValue(color),
'--b-spinner-color': cssVar(color),
...style,
}}
className={classNames(
Expand Down
4 changes: 2 additions & 2 deletions packages/bezier-react/src/components/Status/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import type { SemanticNames } from '~/src/foundation'

import {
cssVarValue,
cssVar,
px,
} from '~/src/utils/style'

Expand Down Expand Up @@ -59,7 +59,7 @@ export const Status = memo(forwardRef(function Status({
style={{
...style,
'--b-status-size': px(size),
'--b-status-bg-color': cssVarValue(backgroundColor),
'--b-status-bg-color': cssVar(backgroundColor),
'--b-status-border-width': px(getStatusCircleBorderWidth(size)),
}}
{...rest}
Expand Down
14 changes: 7 additions & 7 deletions packages/bezier-react/src/utils/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { TokenPrefix } from '~/src/types/Token'

import { split } from './object'
import {
cssVarValue,
tokenCssVarValue,
cssVar,
tokenCssVar,
} from './style'

const bezierComponentProps: Array<keyof BezierComponentProps> = [
Expand Down Expand Up @@ -149,17 +149,17 @@ export function getLayoutStyle<Props extends LayoutProps>(props: Props) {
'--b-left': left,
'--b-shrink': shrink,
'--b-grow': grow,
'--b-bg-color': cssVarValue(bgColor),
'--b-border-color': cssVarValue(borderColor),
'--b-border-radius': tokenCssVarValue(borderRadius && `${TokenPrefix.Radius}-${borderRadius}`),
'--b-bg-color': cssVar(bgColor),
'--b-border-color': cssVar(borderColor),
'--b-border-radius': tokenCssVar(borderRadius && `${TokenPrefix.Radius}-${borderRadius}`),
'--b-border-width': borderWidth,
'--b-border-top-width': borderTopWidth,
'--b-border-right-width': borderRightWidth,
'--b-border-bottom-width': borderBottomWidth,
'--b-border-left-width': borderLeftWidth,
'--b-border-style': borderStyle,
'--b-elevation': tokenCssVarValue(elevation && `${TokenPrefix.Elevation}-${elevation}`),
'--b-z-index': tokenCssVarValue(zIndex && `${TokenPrefix.ZIndex}-${zIndex}`),
'--b-elevation': tokenCssVar(elevation && `${TokenPrefix.Elevation}-${elevation}`),
'--b-z-index': tokenCssVar(zIndex && `${TokenPrefix.ZIndex}-${zIndex}`),
'--b-overflow': overflow,
'--b-overflow-x': overflowX,
'--b-overflow-y': overflowY,
Expand Down
6 changes: 3 additions & 3 deletions packages/bezier-react/src/utils/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function touchableHover(interpolation: InjectedInterpolation): InjectedIn

export const px = <Value extends number | undefined>(value: Value) => (!isNil(value) ? `${value}px` as const : undefined)

export function cssVarValue<
export function cssVar<
PropertyName extends string | undefined,
>(propertyName: PropertyName) {
/* eslint-disable no-nested-ternary */
Expand All @@ -48,10 +48,10 @@ export function cssVarValue<
/* eslint-enable no-nested-ternary */
}

export function tokenCssVarValue<
export function tokenCssVar<

Check warning on line 51 in packages/bezier-react/src/utils/style.ts

View check run for this annotation

Codecov / codecov/patch

packages/bezier-react/src/utils/style.ts#L51

Added line #L51 was not covered by tests
PropertyName extends FlattenAllToken | undefined,
>(propertyName: PropertyName) {
return cssVarValue(propertyName)
return cssVar(propertyName)

Check warning on line 54 in packages/bezier-react/src/utils/style.ts

View check run for this annotation

Codecov / codecov/patch

packages/bezier-react/src/utils/style.ts#L54

Added line #L54 was not covered by tests
}

export function cssUrl(url: string | undefined) {
Expand Down

0 comments on commit fbd6669

Please sign in to comment.