@ezpg/app-ui 0.8.0 → 0.10.0

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/lib/module/adjust/adjust-template.js +92 -0
  3. package/lib/module/adjust/adjust-template.js.map +1 -0
  4. package/lib/module/adjust/color-adjust-note.js +67 -0
  5. package/lib/module/adjust/color-adjust-note.js.map +1 -0
  6. package/lib/module/adjust/color-track.js +132 -0
  7. package/lib/module/adjust/color-track.js.map +1 -0
  8. package/lib/module/adjust/dial-strip.js +126 -0
  9. package/lib/module/adjust/dial-strip.js.map +1 -0
  10. package/lib/module/adjust/hsl.js +29 -0
  11. package/lib/module/adjust/hsl.js.map +1 -0
  12. package/lib/module/adjust/index.js +9 -0
  13. package/lib/module/adjust/index.js.map +1 -0
  14. package/lib/module/adjust/scrub-ruler.js +159 -0
  15. package/lib/module/adjust/scrub-ruler.js.map +1 -0
  16. package/lib/module/adjust.js +4 -0
  17. package/lib/module/adjust.js.map +1 -0
  18. package/lib/module/templates/index.js +1 -0
  19. package/lib/module/templates/index.js.map +1 -1
  20. package/lib/module/templates/intro-template.js +136 -0
  21. package/lib/module/templates/intro-template.js.map +1 -0
  22. package/lib/typescript/src/adjust/adjust-template.d.ts +13 -0
  23. package/lib/typescript/src/adjust/adjust-template.d.ts.map +1 -0
  24. package/lib/typescript/src/adjust/color-adjust-note.d.ts +10 -0
  25. package/lib/typescript/src/adjust/color-adjust-note.d.ts.map +1 -0
  26. package/lib/typescript/src/adjust/color-track.d.ts +12 -0
  27. package/lib/typescript/src/adjust/color-track.d.ts.map +1 -0
  28. package/lib/typescript/src/adjust/dial-strip.d.ts +16 -0
  29. package/lib/typescript/src/adjust/dial-strip.d.ts.map +1 -0
  30. package/lib/typescript/src/adjust/hsl.d.ts +4 -0
  31. package/lib/typescript/src/adjust/hsl.d.ts.map +1 -0
  32. package/lib/typescript/src/adjust/index.d.ts +7 -0
  33. package/lib/typescript/src/adjust/index.d.ts.map +1 -0
  34. package/lib/typescript/src/adjust/scrub-ruler.d.ts +13 -0
  35. package/lib/typescript/src/adjust/scrub-ruler.d.ts.map +1 -0
  36. package/lib/typescript/src/adjust.d.ts +2 -0
  37. package/lib/typescript/src/adjust.d.ts.map +1 -0
  38. package/lib/typescript/src/templates/index.d.ts +2 -0
  39. package/lib/typescript/src/templates/index.d.ts.map +1 -1
  40. package/lib/typescript/src/templates/intro-template.d.ts +16 -0
  41. package/lib/typescript/src/templates/intro-template.d.ts.map +1 -0
  42. package/package.json +6 -1
  43. package/src/adjust/adjust-template.tsx +89 -0
  44. package/src/adjust/color-adjust-note.tsx +61 -0
  45. package/src/adjust/color-track.tsx +140 -0
  46. package/src/adjust/dial-strip.tsx +142 -0
  47. package/src/adjust/hsl.ts +37 -0
  48. package/src/adjust/index.ts +9 -0
  49. package/src/adjust/scrub-ruler.tsx +160 -0
  50. package/src/adjust.tsx +1 -0
  51. package/src/templates/index.ts +2 -0
  52. package/src/templates/intro-template.tsx +153 -0
@@ -0,0 +1,153 @@
1
+ import { useRef, useState, type ComponentRef, type ReactNode } from 'react';
2
+ import {
3
+ ScrollView,
4
+ View,
5
+ type LayoutChangeEvent,
6
+ type NativeScrollEvent,
7
+ type NativeSyntheticEvent,
8
+ } from 'react-native';
9
+ import { Button } from '../components/button/button';
10
+ import { Text } from '../components/text/text';
11
+ import { PressableBase } from '../internal/pressable-base';
12
+ import { useTheme } from '../theme/theme-provider';
13
+ import { makeStyles } from '../utils/styles';
14
+
15
+ export type IntroPage = {
16
+ key: string;
17
+ title: string;
18
+ art: (width: number) => ReactNode;
19
+ };
20
+
21
+ export type IntroTemplateProps = {
22
+ pages: readonly IntroPage[];
23
+ onDone: () => void;
24
+ nextLabel?: string;
25
+ doneLabel?: string;
26
+ skipLabel?: string;
27
+ bottomInset?: number;
28
+ };
29
+
30
+ const useStyles = makeStyles((t) => ({
31
+ root: { flex: 1, backgroundColor: t.colors.background },
32
+ top: {
33
+ height: t.minTouchSize,
34
+ flexDirection: 'row',
35
+ justifyContent: 'flex-end',
36
+ paddingHorizontal: t.layout.screenX,
37
+ },
38
+ skip: {
39
+ minWidth: t.minTouchSize,
40
+ alignItems: 'flex-end',
41
+ justifyContent: 'center',
42
+ },
43
+ pager: { flex: 1 },
44
+ page: {
45
+ flex: 1,
46
+ justifyContent: 'center',
47
+ gap: t.layout.titleGap,
48
+ paddingHorizontal: t.layout.screenX,
49
+ },
50
+ title: { textAlign: 'center' },
51
+ footer: {
52
+ gap: t.layout.titleGap,
53
+ paddingHorizontal: t.layout.screenX,
54
+ paddingTop: t.layout.footerTop,
55
+ },
56
+ dots: {
57
+ flexDirection: 'row',
58
+ justifyContent: 'center',
59
+ gap: t.space[2],
60
+ },
61
+ dot: {
62
+ width: t.space[2],
63
+ height: t.space[2],
64
+ borderRadius: t.radius.full,
65
+ backgroundColor: t.colors.input,
66
+ },
67
+ dotOn: { width: t.space[5], backgroundColor: t.colors.primary },
68
+ }));
69
+
70
+ export function IntroTemplate({
71
+ pages,
72
+ onDone,
73
+ nextLabel = '다음',
74
+ doneLabel = '시작하기',
75
+ skipLabel = 'Skip',
76
+ bottomInset = 0,
77
+ }: IntroTemplateProps) {
78
+ const t = useTheme();
79
+ const s = useStyles();
80
+ const pager = useRef<ComponentRef<typeof ScrollView>>(null);
81
+ const [width, setWidth] = useState(0);
82
+ const [index, setIndex] = useState(0);
83
+ const last = index >= pages.length - 1;
84
+ const art = Math.max(0, width - t.layout.screenX * 2);
85
+
86
+ const next = () => {
87
+ if (last) {
88
+ onDone();
89
+ return;
90
+ }
91
+ pager.current?.scrollTo({ x: (index + 1) * width, animated: true });
92
+ setIndex(index + 1);
93
+ };
94
+
95
+ return (
96
+ <View style={s.root}>
97
+ <View style={s.top}>
98
+ {last ? null : (
99
+ <PressableBase
100
+ onPress={onDone}
101
+ accessibilityLabel={skipLabel}
102
+ style={s.skip}
103
+ >
104
+ <Text variant="caption" tone="muted">
105
+ {skipLabel}
106
+ </Text>
107
+ </PressableBase>
108
+ )}
109
+ </View>
110
+ <ScrollView
111
+ ref={pager}
112
+ horizontal
113
+ pagingEnabled
114
+ showsHorizontalScrollIndicator={false}
115
+ onLayout={(e: LayoutChangeEvent) =>
116
+ setWidth(e.nativeEvent.layout.width)
117
+ }
118
+ onMomentumScrollEnd={(e: NativeSyntheticEvent<NativeScrollEvent>) =>
119
+ width && setIndex(Math.round(e.nativeEvent.contentOffset.x / width))
120
+ }
121
+ style={s.pager}
122
+ >
123
+ {pages.map((page) => (
124
+ <View key={page.key} style={[s.page, { width }]}>
125
+ {art ? page.art(art) : null}
126
+ <Text
127
+ variant="screenTitle"
128
+ accessibilityRole="header"
129
+ style={s.title}
130
+ >
131
+ {page.title}
132
+ </Text>
133
+ </View>
134
+ ))}
135
+ </ScrollView>
136
+ <View
137
+ style={[
138
+ s.footer,
139
+ { paddingBottom: t.layout.footerBottom + bottomInset },
140
+ ]}
141
+ >
142
+ <View style={s.dots}>
143
+ {pages.map((page, i) => (
144
+ <View key={page.key} style={[s.dot, i === index && s.dotOn]} />
145
+ ))}
146
+ </View>
147
+ <Button size="lg" onPress={next}>
148
+ {last ? doneLabel : nextLabel}
149
+ </Button>
150
+ </View>
151
+ </View>
152
+ );
153
+ }