@ecohouse/ui 0.1.14 → 0.1.16
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.
- package/dist/index.cjs +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/SegmentedToggle/SegmentedToggle.tsx +4 -2
- package/src/theme/colors.test.ts +3 -0
- package/src/theme/typography.ts +3 -3
package/package.json
CHANGED
|
@@ -36,6 +36,7 @@ export interface SegmentedToggleProps extends Omit<ViewProps, "style" | "childre
|
|
|
36
36
|
|
|
37
37
|
const ICON_SIZE = 20;
|
|
38
38
|
const ANIMATION_DURATION = 200;
|
|
39
|
+
const OPTION_HORIZONTAL_PADDING = 16;
|
|
39
40
|
|
|
40
41
|
export const SegmentedToggle = forwardRef<ComponentRef<typeof View>, SegmentedToggleProps>(
|
|
41
42
|
function SegmentedToggle(
|
|
@@ -69,7 +70,8 @@ export const SegmentedToggle = forwardRef<ComponentRef<typeof View>, SegmentedTo
|
|
|
69
70
|
const [containerWidth, setContainerWidth] = useState(0);
|
|
70
71
|
const availableOptionWidth = Math.max(0, (containerWidth - 12) / 2);
|
|
71
72
|
const widestContentWidth = Math.max(...contentWidths);
|
|
72
|
-
const contentBasedOptionWidth =
|
|
73
|
+
const contentBasedOptionWidth =
|
|
74
|
+
widestContentWidth > 0 ? widestContentWidth + OPTION_HORIZONTAL_PADDING * 2 : 0;
|
|
73
75
|
const optionWidth = fullWidth ? availableOptionWidth : contentBasedOptionWidth;
|
|
74
76
|
const indicatorTranslateX = progress.interpolate({
|
|
75
77
|
inputRange: [0, 1],
|
|
@@ -193,7 +195,7 @@ const styles = StyleSheet.create({
|
|
|
193
195
|
flexDirection: "row",
|
|
194
196
|
alignItems: "center",
|
|
195
197
|
justifyContent: "center",
|
|
196
|
-
paddingHorizontal:
|
|
198
|
+
paddingHorizontal: OPTION_HORIZONTAL_PADDING,
|
|
197
199
|
borderRadius: 60,
|
|
198
200
|
},
|
|
199
201
|
optionContent: {
|
package/src/theme/colors.test.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { colors } from "./colors";
|
|
|
3
3
|
import {
|
|
4
4
|
buttonTypography,
|
|
5
5
|
inputTypography,
|
|
6
|
+
segmentedToggleTypography,
|
|
6
7
|
selectTypography,
|
|
7
8
|
textareaTypography,
|
|
8
9
|
} from "./typography";
|
|
@@ -20,6 +21,8 @@ describe("design tokens", () => {
|
|
|
20
21
|
expect(colors.whiteAlpha5).toBe("#FFFFFF0D");
|
|
21
22
|
expect(buttonTypography.lg.fontSize).toBe(14);
|
|
22
23
|
expect(buttonTypography.lg.fontWeight).toBe("600");
|
|
24
|
+
expect(segmentedToggleTypography.fontSize).toBe(12);
|
|
25
|
+
expect(segmentedToggleTypography.lineHeight).toBe(12);
|
|
23
26
|
});
|
|
24
27
|
|
|
25
28
|
it("keeps Input, Select, and Textarea field text aligned", () => {
|
package/src/theme/typography.ts
CHANGED
|
@@ -38,12 +38,12 @@ export const statCardTypography = {
|
|
|
38
38
|
letterSpacing: 0,
|
|
39
39
|
} as const;
|
|
40
40
|
|
|
41
|
-
/** Segmented toggle label — Medium
|
|
41
|
+
/** Segmented toggle label — Medium 12, line-height 100%, letter-spacing 0. */
|
|
42
42
|
export const segmentedToggleTypography = {
|
|
43
43
|
fontFamily: fonts.sans,
|
|
44
|
-
fontSize:
|
|
44
|
+
fontSize: 12,
|
|
45
45
|
fontWeight: "500" as const,
|
|
46
|
-
lineHeight:
|
|
46
|
+
lineHeight: 12,
|
|
47
47
|
letterSpacing: 0,
|
|
48
48
|
} as const;
|
|
49
49
|
|