Skip to content

🎥 Make videos programmatically with React

smaller checkbox

JonnyBurgerb085eddcfcb9
diff --git a/packages/studio/src/components/Checkbox.tsx b/packages/studio/src/components/Checkbox.tsx
index 0ffe79dd45..2f7d1adfcd 100644
--- a/packages/studio/src/components/Checkbox.tsx
+++ b/packages/studio/src/components/Checkbox.tsx
@@ -6,33 +6,22 @@ import {
} from '../helpers/colors';
import {Checkmark} from '../icons/Checkmark';
-const size = 20;
+const SIZES = {
+ default: 20,
+ small: 18,
+} as const;
-const background: React.CSSProperties = {
- height: size,
- width: size,
- position: 'relative',
-};
+const BULLET_SIZES = {
+ default: 10,
+ small: 9,
+} as const;
-const bullet: React.CSSProperties = {
- width: 10,
- height: 10,
- backgroundColor: LIGHT_TEXT,
- borderRadius: '50%',
-};
+const CHECKMARK_SIZES = {
+ default: 14,
+ small: 13,
+} as const;
-const box: React.CSSProperties = {
- display: 'flex',
- justifyContent: 'center',
- alignItems: 'center',
- position: 'absolute',
- height: size,
- width: size,
- top: 0,
- left: 0,
- pointerEvents: 'none',
- color: 'white',
-};
+export type CheckboxVariant = keyof typeof SIZES;
export const Checkbox: React.FC<{
readonly checked: boolean;
@@ -40,8 +29,48 @@ export const Checkbox: React.FC<{
readonly name: string;
readonly rounded?: boolean;
readonly disabled?: boolean;
-}> = ({checked, onChange, disabled, name, rounded}) => {
+ readonly variant?: CheckboxVariant;
+}> = ({checked, onChange, disabled, name, rounded, variant = 'default'}) => {
const ref = useRef<HTMLInputElement>(null);
+ const size = SIZES[variant];
+ const bulletSize = BULLET_SIZES[variant];
+ const checkmarkSize = CHECKMARK_SIZES[variant];
+
+ const background: React.CSSProperties = useMemo(
+ () => ({
+ height: size,
+ width: size,
+ position: 'relative',
+ }),
+ [size],
+ );
+
+ const bullet: React.CSSProperties = useMemo(
+ () => ({
+ width: bulletSize,
+ height: bulletSize,
+ backgroundColor: LIGHT_TEXT,
+ borderRadius: '50%',
+ }),
+ [bulletSize],
+ );
+
+ const box: React.CSSProperties = useMemo(
+ () => ({
+ display: 'flex',
+ justifyContent: 'center',
+ alignItems: 'center',
+ position: 'absolute',
+ height: size,
+ width: size,
+ top: 0,
+ left: 0,
+ pointerEvents: 'none',
+ color: 'white',
+ }),
+ [size],
+ );
+
const input: React.CSSProperties = useMemo(() => {
return {
appearance: 'none',
@@ -54,7 +83,7 @@ export const Checkbox: React.FC<{
position: 'absolute',
margin: 0,
};
- }, [disabled]);
+ }, [disabled, size]);
useEffect(() => {
if (ref.current) {
@@ -78,7 +107,13 @@ export const Checkbox: React.FC<{
name={name}
/>
<div style={box}>
- {checked ? rounded ? <div style={bullet} /> : <Checkmark /> : null}
+ {checked ? (
+ rounded ? (
+ <div style={bullet} />
+ ) : (
+ <Checkmark size={checkmarkSize} />
+ )
+ ) : null}
</div>
</div>
);
diff --git a/packages/studio/src/components/Timeline/TimelineBooleanField.tsx b/packages/studio/src/components/Timeline/TimelineBooleanField.tsx
index 314c333b0d..99e4f379d2 100644
--- a/packages/studio/src/components/Timeline/TimelineBooleanField.tsx
+++ b/packages/studio/src/components/Timeline/TimelineBooleanField.tsx
@@ -29,6 +29,7 @@ export const TimelineBooleanField: React.FC<{
onChange={onChange}
name={field.key}
disabled={!canUpdate}
+ variant="small"
/>
</div>
);
diff --git a/packages/studio/src/icons/Checkmark.tsx b/packages/studio/src/icons/Checkmark.tsx
index 5493eeda15..193da50ed0 100644
--- a/packages/studio/src/icons/Checkmark.tsx
+++ b/packages/studio/src/icons/Checkmark.tsx
@@ -1,12 +1,12 @@
import React from 'react';
-const style: React.CSSProperties = {
- width: 14,
- height: 14,
-};
-
-export const Checkmark = () => (
- <svg focusable="false" role="img" viewBox="0 0 512 512" style={style}>
+export const Checkmark: React.FC<{readonly size?: number}> = ({size = 14}) => (
+ <svg
+ focusable="false"
+ role="img"
+ viewBox="0 0 512 512"
+ style={{width: size, height: size}}
+ >
<path
fill="currentColor"
d="M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"