diff --git a/.changeset/early-starfishes-eat.md b/.changeset/early-starfishes-eat.md new file mode 100644 index 000000000..019df025e --- /dev/null +++ b/.changeset/early-starfishes-eat.md @@ -0,0 +1,5 @@ +--- +'@primer/primitives': patch +--- + +Update easing curves diff --git a/docs/storybook/stories/Motion/Base.stories.tsx b/docs/storybook/stories/Motion/Base.stories.tsx index eb1c614c3..25966ea7e 100644 --- a/docs/storybook/stories/Motion/Base.stories.tsx +++ b/docs/storybook/stories/Motion/Base.stories.tsx @@ -4,6 +4,8 @@ import baseMotionTokens from '../../../../dist/docs/base/motion/motion.json' import {DataTable, Table} from '@primer/react/drafts' import {InlineCode} from '../StorybookComponents/InlineCode/InlineCode' import {getTokensByName} from '../utilities/getTokensByName' +import {CubicBezier} from '../StorybookComponents/BezierCurve/BezierCurve' +import {Card} from '../StorybookComponents/Card/Card' export default { title: 'Motion/Base', @@ -36,7 +38,7 @@ export const Base = () => { field: 'name', rowHeader: true, renderCell: row => { - return + return }, }, { @@ -58,39 +60,29 @@ export const Base = () => { ]} /> - -

Base easing

- item.type === 'cubicBezier')} - columns={[ - { - header: 'Token', - field: 'name', - rowHeader: true, - renderCell: row => { - return - }, - }, - { - header: 'Output value', - field: 'value', - rowHeader: true, - renderCell: row => { - return

{JSON.stringify(row.value)}

- }, - }, - { - header: 'Source value', - field: 'original', - rowHeader: true, - renderCell: row => { - return

{JSON.stringify(row.original.$value)}

- }, - }, - ]} - /> -
+ +

Base easing

+
+ {data + .filter(item => item.type === 'cubicBezier') + .map(item => ( + + +

[{item.value.join(', ')}]

+ +
+ ))} +
) } diff --git a/docs/storybook/stories/StorybookComponents/BezierCurve/BezierCurve.tsx b/docs/storybook/stories/StorybookComponents/BezierCurve/BezierCurve.tsx new file mode 100644 index 000000000..034928c89 --- /dev/null +++ b/docs/storybook/stories/StorybookComponents/BezierCurve/BezierCurve.tsx @@ -0,0 +1,44 @@ +import React, {useRef, useEffect} from 'react' + +export const CubicBezier = ({bezier}: {bezier: [number, number, number, number]}) => { + const canvasRef = useRef(null) + const padding = 20 + const lineWidth = '6' + const fillStart = 'purple' + const fillEnd = 'blue' + + // Convert CSS cubic-bezier array to control points + const [x1, y1, x2, y2] = bezier + const p0 = {x: padding, y: 500 - padding} + const p1 = { + x: x1 * (500 - 2 * padding) + padding, + y: 500 - (y1 * (500 - 2 * padding) + padding), + } + const p2 = { + x: x2 * (500 - 2 * padding) + padding, + y: 500 - (y2 * (500 - 2 * padding) + padding), + } + const p3 = {x: 500 - padding, y: padding} + + useEffect(() => { + const canvas = canvasRef.current + const ctx = canvas.getContext('2d') + ctx.clearRect(0, 0, canvas.width, canvas.height) + + // Create gradient + const gradient = ctx.createLinearGradient(p0.x, p0.y, p3.x, p3.y) + gradient.addColorStop(0, fillStart) + gradient.addColorStop(1, fillEnd) + + // Draw bezier curve + ctx.strokeStyle = gradient + ctx.lineWidth = lineWidth + ctx.lineCap = 'round' + ctx.beginPath() + ctx.moveTo(p0.x, p0.y) + ctx.bezierCurveTo(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y) + ctx.stroke() + }, [p0, p1, p2, p3]) + + return +} diff --git a/docs/storybook/stories/StorybookComponents/Card/Card.css b/docs/storybook/stories/StorybookComponents/Card/Card.css new file mode 100644 index 000000000..a3dcf17f4 --- /dev/null +++ b/docs/storybook/stories/StorybookComponents/Card/Card.css @@ -0,0 +1,11 @@ +.Card { + border-radius: var(--borderRadius-default); + border-color: var(--borderColor-default); + border-width: 1px; + border-style: solid; + padding: 16px; + + * { + max-width: 100%; + } +} diff --git a/docs/storybook/stories/StorybookComponents/Card/Card.tsx b/docs/storybook/stories/StorybookComponents/Card/Card.tsx new file mode 100644 index 000000000..2078a94c6 --- /dev/null +++ b/docs/storybook/stories/StorybookComponents/Card/Card.tsx @@ -0,0 +1,15 @@ +import React, {ReactNode} from 'react' +import './Card.css' + +interface CardProps extends React.Component { + children: ReactNode + style: React.CSSProperties +} + +export const Card = ({children, style}: CardProps) => { + return ( +
+ {children} +
+ ) +} diff --git a/src/tokens/base/motion/easing.json5 b/src/tokens/base/motion/easing.json5 index d7bf0a8ae..da3d42798 100644 --- a/src/tokens/base/motion/easing.json5 +++ b/src/tokens/base/motion/easing.json5 @@ -12,7 +12,7 @@ $description: 'Ideal for movement that starts on the page and ends off the page.', }, easeOut: { - $value: [0.16, 1, 0.3, 1], + $value: [0.3, 0.8, 0.6, 1], $type: 'cubicBezier', $description: 'Ideal for movement that starts off the page and ends on the page.', }, diff --git a/src/tokens/base/motion/timing.json5 b/src/tokens/base/motion/timing.json5 index eb6cc9f7b..337200975 100644 --- a/src/tokens/base/motion/timing.json5 +++ b/src/tokens/base/motion/timing.json5 @@ -5,10 +5,6 @@ $value: '0ms', $type: 'duration', }, - '75': { - $value: '75ms', - $type: 'duration', - }, '100': { $value: '100ms', $type: 'duration',