Skip to content

Commit

Permalink
test: toggle contrast ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard committed Oct 12, 2023
1 parent 382253f commit 71231af
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/@sanity/color/src/__workshop__/tool/ColorPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Box, Card, Flex, Text} from '@sanity/ui'
import {Box, Card, Flex, Text, useTheme} from '@sanity/ui'
import {getContrast} from 'polished'
import {memo, useMemo} from 'react'
import {color} from '../../color'
Expand All @@ -14,6 +14,7 @@ export const ColorPreview = memo(function ColorPreview(props: {
showContrast?: boolean
}) {
const {expanded, hsl, showAABadges, showContrast} = props
const {dark} = useTheme().sanity.color

const hex = rgbToHex(hslToRgb(hsl))

Expand Down Expand Up @@ -67,7 +68,7 @@ export const ColorPreview = memo(function ColorPreview(props: {
{showContrast && (
<Box padding={1}>
<Text size={0} weight="bold">
{contrast.light.toFixed(1)}:1
{contrast[dark ? 'dark' : 'light'].toFixed(1)}:1
</Text>
</Box>
)}
Expand Down

0 comments on commit 71231af

Please sign in to comment.