@artsy/palette-mobile 14.0.34 → 14.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -148,7 +148,7 @@ export const Input = forwardRef(({ addClearListener = false, defaultValue, disab
148
148
  fontFamily: fontFamily,
149
149
  };
150
150
  }, [fontFamily, space, color]);
151
- const inputVariants = getInputVariants(theme);
151
+ const inputVariants = useMemo(() => getInputVariants(theme), [theme]);
152
152
  useEffect(() => {
153
153
  const inputState = getInputState({
154
154
  isFocused: !!focused,
@@ -3,17 +3,18 @@ import { TextVariant } from "@artsy/palette-tokens/dist/typography/v3";
3
3
  import { Insets, TouchableWithoutFeedbackProps } from "react-native";
4
4
  import { FlexProps } from "../Flex";
5
5
  export interface RadioButtonProps extends Omit<TouchableWithoutFeedbackProps, "hitSlop">, Omit<FlexProps, "hitSlop"> {
6
- hitSlop?: Insets;
7
- selected?: boolean;
8
- focused?: boolean;
6
+ accessibilityState?: {
7
+ checked: boolean;
8
+ };
9
+ block?: boolean;
9
10
  disabled?: boolean;
10
11
  error?: boolean;
12
+ focused?: boolean;
13
+ hitSlop?: Insets;
14
+ selected?: boolean;
15
+ subtitle?: React.ReactElement | string;
11
16
  text?: React.ReactElement | string;
12
17
  textVariant?: TextVariant;
13
- subtitle?: React.ReactElement | string;
14
- accessibilityState?: {
15
- checked: boolean;
16
- };
17
18
  }
18
19
  export declare const RadioButton: React.FC<RadioButtonProps>;
19
20
  interface RadioDotProps {
@@ -8,13 +8,13 @@ import { Flex } from "../Flex";
8
8
  import { Text } from "../Text";
9
9
  const RADIOBUTTON_SIZE = 20;
10
10
  const DURATION = 150;
11
- export const RadioButton = ({ selected, disabled, error, onPress, text, textVariant = "md", subtitle, accessibilityState, ...restProps }) => {
11
+ export const RadioButton = ({ accessibilityState, block, disabled, error, onPress, selected, subtitle, text, textVariant = "md", ...restProps }) => {
12
12
  const { color, space } = useTheme();
13
13
  const fontScale = PixelRatio.getFontScale();
14
14
  const radioButtonSize = RADIOBUTTON_SIZE * fontScale;
15
15
  const defaultRadioButtonStyle = {
16
16
  backgroundColor: color("white100"),
17
- borderColor: color("black60"),
17
+ borderColor: color("black30"),
18
18
  };
19
19
  const selectedRadioButtonStyle = {
20
20
  backgroundColor: color("black100"),
@@ -39,17 +39,18 @@ export const RadioButton = ({ selected, disabled, error, onPress, text, textVari
39
39
  : radioButtonStyles[error ? "error" : "default"][selected ? "selected" : "notSelected"];
40
40
  const textColor = error ? color("red100") : disabled ? color("black30") : color("black100");
41
41
  const subtitleColor = error ? color("red100") : color("black30");
42
+ const AnimatedDot = (_jsx(Flex, { mt: "2px", children: _jsx(CssTransition, { style: [
43
+ styles(fontScale).container,
44
+ { marginRight: space(1) * fontScale },
45
+ radioButtonStyle,
46
+ ], animate: ["borderColor"], duration: DURATION, children: !!selected &&
47
+ (!!disabled ? (_jsx(DisabledDot, { size: radioButtonSize })) : (_jsx(RadioDot, { size: radioButtonSize }))) }) }));
42
48
  return (_jsx(TouchableWithoutFeedback, { accessibilityState: accessibilityState, onPress: (event) => {
43
49
  if (disabled) {
44
50
  return;
45
51
  }
46
52
  onPress?.(event);
47
- }, children: _jsxs(Flex, { ...restProps, children: [_jsxs(Flex, { flexDirection: "row", alignItems: "center", children: [_jsx(Flex, { mt: "2px", children: _jsx(CssTransition, { style: [
48
- styles(fontScale).container,
49
- { marginRight: space(1) * fontScale },
50
- radioButtonStyle,
51
- ], animate: ["borderColor"], duration: DURATION, children: !!selected &&
52
- (!!disabled ? (_jsx(DisabledDot, { size: radioButtonSize })) : (_jsx(RadioDot, { size: radioButtonSize }))) }) }), _jsx(Flex, { justifyContent: "center", children: !!text && (_jsx(Text, { variant: textVariant, color: textColor, children: text })) })] }), _jsx(Flex, { ml: `${(RADIOBUTTON_SIZE + space(1)) * fontScale}px`, mt: "6px", children: !!subtitle && (_jsx(Text, { variant: "xs", color: subtitleColor, children: subtitle })) })] }) }));
53
+ }, children: _jsxs(Flex, { ...restProps, children: [_jsxs(Flex, { flexDirection: "row", alignItems: "center", justifyContent: block ? "space-between" : "flex-start", children: [!block && AnimatedDot, _jsx(Flex, { justifyContent: "center", children: !!text && (_jsx(Text, { variant: textVariant, color: textColor, children: text })) }), block && AnimatedDot] }), _jsx(Flex, { ml: block ? 0 : `${(RADIOBUTTON_SIZE + space(1)) * fontScale}px`, mt: block ? 0 : 0.5, children: !!subtitle && (_jsx(Text, { variant: "xs", color: subtitleColor, children: subtitle })) })] }) }));
53
54
  };
54
55
  // styled-component does not have support for Animated.View
55
56
  const styles = (fontScale) => StyleSheet.create({
@@ -10,13 +10,15 @@ export default {
10
10
  };
11
11
  storiesOf("RadioButton", module).add("Default", () => {
12
12
  const [metric, setMetric] = useState("cm");
13
- return (_jsx(List, { contentContainerStyle: {
13
+ return (_jsxs(List, { contentContainerStyle: {
14
14
  marginHorizontal: 20,
15
15
  justifyContent: "flex-start",
16
16
  alignItems: "flex-start",
17
- }, children: _jsxs(Flex, { flexDirection: "row", gap: 2, children: [_jsx(RadioButton, { onPress: () => {
17
+ }, children: [_jsxs(Flex, { flexDirection: "row", gap: 2, children: [_jsx(RadioButton, { onPress: () => {
18
+ setMetric("cm");
19
+ }, selected: metric === "cm", text: "centimeters" }), _jsx(RadioButton, { onPress: () => {
20
+ setMetric("in");
21
+ }, selected: metric === "in", text: "inches" })] }), _jsx(Flex, { children: _jsx(RadioButton, { onPress: () => {
18
22
  setMetric("cm");
19
- }, selected: metric === "cm", text: "centimeters" }), _jsx(RadioButton, { onPress: () => {
20
- setMetric("in");
21
- }, selected: metric === "in", text: "inches" })] }) }));
23
+ }, block: true, selected: metric === "cm", text: "centimeters" }) })] }));
22
24
  });
@@ -1,54 +1,50 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Flex } from "../Flex";
3
+ const INACTIVE_BORDER_WIDTH = 2;
4
+ const ACTIVE_BORDER_WIDTH = 4;
3
5
  export const RADIO_DOT_MODES = {
4
6
  default: {
5
7
  resting: {
6
- borderWidth: 2,
7
- borderColor: "black10",
8
+ borderWidth: INACTIVE_BORDER_WIDTH,
9
+ borderColor: "black30",
8
10
  },
9
11
  selected: {
10
- borderWidth: 2,
12
+ borderWidth: ACTIVE_BORDER_WIDTH,
11
13
  borderColor: "black100",
12
- backgroundColor: "black100",
13
14
  },
14
15
  },
15
16
  disabled: {
16
17
  resting: {
17
- borderWidth: 2,
18
+ borderWidth: INACTIVE_BORDER_WIDTH,
18
19
  borderColor: "black10",
19
- backgroundColor: "black10",
20
20
  },
21
21
  selected: {
22
- borderWidth: 2,
22
+ borderWidth: ACTIVE_BORDER_WIDTH,
23
23
  borderColor: "black10",
24
- backgroundColor: "black10",
25
24
  },
26
25
  },
27
26
  error: {
28
27
  resting: {
29
- borderWidth: 2,
28
+ borderWidth: INACTIVE_BORDER_WIDTH,
30
29
  borderColor: "red100",
31
30
  },
32
31
  selected: {
33
- borderWidth: 2,
32
+ borderWidth: ACTIVE_BORDER_WIDTH,
34
33
  borderColor: "black100",
35
- backgroundColor: "black100",
36
34
  },
37
35
  },
38
36
  hover: {
39
37
  resting: {
40
- borderWidth: 2,
38
+ borderWidth: INACTIVE_BORDER_WIDTH,
41
39
  borderColor: "black10",
42
- backgroundColor: "black10",
43
40
  },
44
41
  selected: {
45
- borderWidth: 2,
42
+ borderWidth: INACTIVE_BORDER_WIDTH,
46
43
  borderColor: "black100",
47
- backgroundColor: "black100",
48
44
  },
49
45
  },
50
46
  };
51
- export const RadioDot = (props) => (_jsx(Container, { ...props, children: _jsx(Dot, { ...props }) }));
47
+ export const RadioDot = (props) => (_jsx(Container, { ...props, children: _jsx(Dot, {}) }));
52
48
  const Container = ({ selected = false, hover = false, error = false, disabled = false, }) => {
53
49
  const mode = (() => {
54
50
  switch (true) {
@@ -65,4 +61,4 @@ const Container = ({ selected = false, hover = false, error = false, disabled =
65
61
  const moreProps = selected ? mode.selected : mode.resting;
66
62
  return (_jsx(Flex, { width: 20, height: 20, borderRadius: 50, alignItems: "center", justifyContent: "center", flexShrink: 0, ...moreProps }));
67
63
  };
68
- const Dot = ({ selected = false, disabled = false }) => (_jsx(Flex, { width: 10, height: 10, borderRadius: 50, alignItems: "center", justifyContent: "center", flexShrink: 0, backgroundColor: disabled && !selected ? "transparent" : "white100" }));
64
+ const Dot = () => (_jsx(Flex, { width: 12, height: 12, borderRadius: 50, alignItems: "center", justifyContent: "center", flexShrink: 0 }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "14.0.34",
3
+ "version": "14.0.36",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "scripts": {
6
6
  "android": "RCT_METRO_PORT=8082 react-native run-android --port 8082 --terminal terminal",