Skip to content

Commit 9676e19

Browse files
committed
feat: add button ogp-spinner
1 parent 4ab3580 commit 9676e19

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { SVGProps } from 'react'
2+
3+
export const OgpLogo = (props: SVGProps<SVGSVGElement>) => {
4+
return (
5+
<svg
6+
xmlns="http://www.w3.org/2000/svg"
7+
viewBox="0 0 32 32"
8+
fill="none"
9+
{...props}
10+
>
11+
<mask
12+
mask-type="alpha"
13+
maskUnits="userSpaceOnUse"
14+
x="2"
15+
y="4"
16+
width="9"
17+
height="24"
18+
>
19+
<path d="M2.3 4H10.8V28H2.3V4Z" fill="#CCC" />
20+
</mask>
21+
<g mask="url(#mask0)">
22+
<path
23+
d="M10.7 25.6C10.8 25.4 10.8 25.3 10.7 25.1 10.7 25 10.6 24.8 10.5 24.8 7.7 22.9 5.9 19.7 5.9 16 5.9 12.3 7.7 9.1 10.5 7.2 10.6 7.2 10.7 7 10.7 6.9 10.8 6.7 10.8 6.6 10.7 6.4L9.5 4.3C9.4 4.2 9.4 4.2 9.3 4.1 9.3 4.1 9.2 4 9.1 4 9 4 8.9 4 8.9 4 8.8 4 8.7 4.1 8.6 4.1 4.8 6.6 2.3 11 2.3 16 2.3 21 4.8 25.4 8.6 27.9 8.7 27.9 8.8 28 8.9 28 8.9 28 9 28 9.1 28 9.2 28 9.3 27.9 9.3 27.9 9.4 27.8 9.4 27.8 9.5 27.7L10.7 25.6Z"
24+
fill="currentColor"
25+
/>
26+
</g>
27+
<path
28+
d="M22.6 4.3L21.5 6.4C21.4 6.6 21.4 6.7 21.4 6.9 21.4 7 21.5 7.2 21.6 7.2 24.4 9.1 26.3 12.3 26.3 16 26.3 19.7 24.4 22.9 21.6 24.8 21.5 24.8 21.4 25 21.4 25.1 21.4 25.3 21.4 25.4 21.5 25.6L22.6 27.7C22.7 27.8 22.7 27.8 22.8 27.9 22.9 27.9 23 28 23 28 23.1 28 23.2 28 23.3 28 23.4 28 23.4 27.9 23.5 27.9 27.3 25.4 29.8 21 29.8 16 29.8 11 27.3 6.6 23.5 4.1 23.4 4.1 23.4 4 23.3 4 23.2 4 23.1 4 23 4 23 4 22.9 4.1 22.8 4.1 22.7 4.2 22.7 4.2 22.6 4.3"
29+
fill="currentColor"
30+
/>
31+
</svg>
32+
)
33+
}

frontend/src/components/Button/Button.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import {
44
forwardRef,
55
IconProps,
66
} from '@chakra-ui/react'
7+
import { useGrowthBook } from '@growthbook/growthbook-react'
8+
9+
import { featureFlags } from '~shared/constants'
10+
11+
import { OgpLogo } from '~assets/svgrs/brand/OgpLogo'
712

813
import Spinner from '../Spinner'
914

@@ -30,10 +35,28 @@ export const Button = forwardRef<ButtonProps, 'button'>(
3035
{ children, spinnerFontSize, isFullWidth, isHighContrast, ...props },
3136
ref,
3237
) => {
38+
const gb = useGrowthBook()
39+
40+
// Ensures compatibility between Chakra size definitions and those supported by the SVG logo
41+
const spinnerSize =
42+
typeof spinnerFontSize === 'string' || typeof spinnerFontSize === 'number'
43+
? spinnerFontSize
44+
: '1.5rem'
45+
46+
const spinner = gb?.isOn(featureFlags.ogpSpinner) ? (
47+
<Spinner
48+
fontSize={spinnerFontSize ?? '1.5rem'}
49+
speed="1s"
50+
element={<OgpLogo height={spinnerSize} fill="primary" />}
51+
/>
52+
) : (
53+
<Spinner fontSize={spinnerFontSize ?? '1.5rem'} />
54+
)
55+
3356
return (
3457
<ChakraButton
3558
ref={ref}
36-
spinner={<Spinner fontSize={spinnerFontSize ?? '1.5rem'} />}
59+
spinner={spinner}
3760
width={isFullWidth ? '100%' : undefined}
3861
{...props}
3962
{...(isFullWidth ? { minH: '3.5rem' } : {})}

shared/constants/feature-flags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ export const featureFlags = {
2828
singpassMrf: 'singpass-mrf' as const,
2929
enableSaveDraftButtonFloating: 'enable-save-draft-button-floating' as const,
3030
enableSaveDraftButtonHeader: 'enable-save-draft-button-header' as const,
31+
ogpSpinner: 'ogp-spinner' as const,
3132
}

0 commit comments

Comments
 (0)