Skip to content

Commit b5fb1f3

Browse files
authored
Infra/ migrate Card to designTokens (#1919)
* migrate Card to designTokens * PR fixes
1 parent 1041485 commit b5fb1f3

File tree

2 files changed

+37
-39
lines changed

2 files changed

+37
-39
lines changed

demo/src/screens/componentScreens/CardsScreen.tsx

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
4444
onPress={() => this.setState({selected2: !selected2})}
4545
activeOpacity={1}
4646
selectionOptions={{
47-
color: Colors.grey10,
47+
color: Colors.grey40,
4848
indicatorSize: 25,
4949
borderWidth: 3
5050
}}
@@ -59,13 +59,13 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
5959
return (
6060
<Card.Section
6161
content={[
62-
{text: 'You’re Invited!', text70: true, grey10: true},
62+
{text: 'You’re Invited!', text70: true, $textDefault: true},
6363
{
6464
text: '222 Join Old The Town Barbershop Official Store. Download the Wix app to...',
6565
text80: true,
66-
grey10: true
66+
$textDefault: true
6767
},
68-
{text: 'wix.to/A465c', text90: true, grey50: true}
68+
{text: 'wix.to/A465c', text90: true, $textDisabled: true}
6969
]}
7070
style={{padding: 20, flex: 1}}
7171
/>
@@ -75,14 +75,14 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
7575
renderText = () => {
7676
return (
7777
<View padding-20 flex>
78-
<Text text70 grey10>
78+
<Text text70 $textDefault>
7979
You’re Invited!
8080
</Text>
81-
<Text text80 grey10>
81+
<Text text80 $textDefault>
8282
222 Join Old The Town Barbershop Official Store. Download the Wix app
8383
to...
8484
</Text>
85-
<Text text90 grey50>
85+
<Text text90 $textDisabled>
8686
wix.to/A465c
8787
</Text>
8888
</View>
@@ -98,7 +98,7 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
9898
onPress={() => {}}
9999
borderRadius={borderRadius}
100100
useNative
101-
backgroundColor={Colors.white}
101+
bg-$backgroundElevated
102102
activeOpacity={1}
103103
activeScale={isImageOnLeft ? 0.96 : 1.04}
104104
>
@@ -123,10 +123,9 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
123123
return (
124124
<Card style={{marginBottom: 10}} onPress={() => {}}>
125125
<Card.Section
126-
bg-white
127126
content={[
128-
{text: 'You’re Invited!', text70: true, grey10: true},
129-
{text: 'join now', text90: true, grey50: true}
127+
{text: 'You’re Invited!', text70: true, $textDefault: true},
128+
{text: 'join now', text90: true, $textDisabled: true}
130129
]}
131130
style={{padding: 20}}
132131
/>
@@ -139,20 +138,20 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
139138
return (
140139
<Card {...cardProps} flex height={160} onPress={() => {}} useNative activeOpacity={1} activeScale={0.96}>
141140
<Card.Section
142-
bg-red30
141+
bg-$backgroundDangerHeavy
143142
padding-20
144143
flex-3
145144
content={[
146-
{text: 'Special sale!', text70: true, white: true},
147-
{text: '10%', text60: true, white: true}
145+
{text: 'Special sale!', text70: true, $textDefaultLight: true},
146+
{text: '10%', text60: true, $textDefaultLight: true}
148147
]}
149148
contentStyle={{alignItems: 'center'}}
150149
/>
151150
<Card.Section
152-
bg-white
151+
bg-$backgroundElevated
153152
padding-20
154153
flex
155-
content={[{text: 'All site', text70: true, grey10: true}]}
154+
content={[{text: 'All site', text70: true, $textDefault: true}]}
156155
contentStyle={{alignItems: 'center', margin: 0, padding: 0}}
157156
/>
158157
</Card>
@@ -173,9 +172,9 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
173172
<Card {...cardProps} flex marginV-10 onPress={() => {}} useNative activeOpacity={1} activeScale={0.96}>
174173
{image}
175174
<Card.Section
176-
bg-white
175+
bg-$backgroundElevated
177176
padding-20
178-
content={[{text: 'All site', text70: true, grey10: true}]}
177+
content={[{text: 'All site', text70: true, $textDefault: true}]}
179178
contentStyle={{alignItems: 'center'}}
180179
/>
181180
</Card>
@@ -190,7 +189,6 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
190189
this.renderComplexImage({'marginR-5': true},
191190
<Card.Section
192191
flex
193-
backgroundColor={Colors.blue20}
194192
imageSource={featureIcon}
195193
imageStyle={{
196194
width: 25,
@@ -211,8 +209,8 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
211209
imageSource={cardImage2}
212210
imageStyle={{height: '100%'}}
213211
content={[
214-
{text: 'Special sale!', text70: true, blue10: true},
215-
{text: '10%', text60: true, blue10: true}
212+
{text: 'Special sale!', text70: true, $textGeneral: true},
213+
{text: '10%', text60: true, $textGeneral: true}
216214
]}
217215
contentStyle={{
218216
flex: 1,
@@ -230,9 +228,9 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
230228
<ScrollView style={{height: 100, marginBottom: 20}} horizontal showsHorizontalScrollIndicator={false}>
231229
{_.times(4, i => {
232230
return (
233-
<Card key={i} width={100} style={{marginRight: 20}} backgroundColor={Colors.white}>
231+
<Card key={i} width={100} style={{marginRight: 20}}>
234232
<View padding-15>
235-
<Text text30 grey30>
233+
<Text text30 $textNeutral>
236234
{i}
237235
</Text>
238236
</View>
@@ -253,7 +251,7 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
253251

254252
renderComplexExample = () => {
255253
return _.map(posts, (post, i) => {
256-
const statusColor = post.status === 'Published' ? Colors.green30 : Colors.orange30;
254+
const statusColor = post.status === 'Published' ? Colors.$textSuccess : Colors.$textMajor;
257255

258256
return (
259257
<Card
@@ -266,23 +264,23 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
266264
imageStyle={{height: 160}}
267265
/>
268266

269-
<View padding-20 bg-white>
270-
<Text text40 color={Colors.grey10}>
267+
<View padding-20>
268+
<Text text40 $textDefault>
271269
{post.title}
272270
</Text>
273271
<View row>
274272
<Text text90 color={statusColor}>
275273
{post.status}
276274
</Text>
277-
<Text text90> | {post.timestamp}</Text>
275+
<Text text90 $textDefault> | {post.timestamp}</Text>
278276
</View>
279277

280-
<Text text70 color={Colors.grey10}>
278+
<Text text70 $textDefault>
281279
{post.description}
282280
</Text>
283281

284282
<View>
285-
<Text text90 color={Colors.grey50}>
283+
<Text text90 $textDisabled>
286284
{post.likes} Likes
287285
</Text>
288286
<View row right>
@@ -314,25 +312,25 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
314312

315313
render() {
316314
return (
317-
<View bg-grey70>
315+
<View>
318316
<ScrollView>
319317
<View flex padding-20>
320-
<Text h1 marginB-s4>Cards</Text>
321-
<Text h3>Selectable Cards</Text>
318+
<Text h1 marginB-s4 $textDefault>Cards</Text>
319+
<Text h3 $textDefault>Selectable Cards</Text>
322320
{this.renderSelectableCards()}
323-
<Text h3 marginV-s5>
321+
<Text h3 marginV-s5 $textDefault>
324322
Horizontal Cards
325323
</Text>
326324
{this.renderHorizontalCard(true, 0, true)}
327325
{this.renderHorizontalCard(true, 20, false)}
328326
{this.renderHorizontalCard(false, 0, false)}
329327
{this.renderHorizontalCard(false, 20, true)}
330-
<Text h3 marginV-s5>
328+
<Text h3 marginV-s5 $textDefault>
331329
Card Sections
332330
</Text>
333331
{this.renderCoupons()}
334332
{this.renderComplexImages()}
335-
<Text h3 marginB-s4>
333+
<Text h3 marginB-s4 $textDefault>
336334
Others
337335
</Text>
338336
{this.renderCustomContent()}

src/components/card/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ const BlurView = BlurViewPackage?.BlurView;
2020
const DEFAULT_BORDER_RADIUS = BorderRadiuses.br40;
2121
const DEFAULT_SELECTION_PROPS = {
2222
borderWidth: 2,
23-
color: Colors.primary,
23+
color: Colors.$backgroundPrimaryHeavy,
2424
indicatorSize: 20,
2525
icon: Assets.icons.checkSmall,
26-
iconColor: Colors.white,
26+
iconColor: Colors.$iconDefaultLight,
2727
hideIndicator: false
2828
};
2929

@@ -186,7 +186,7 @@ class Card extends PureComponent<PropTypes, State> {
186186
}
187187

188188
get backgroundStyle() {
189-
const {enableBlur, backgroundColor = Colors.white} = this.props;
189+
const {enableBlur, backgroundColor = Colors.$backgroundElevated} = this.props;
190190

191191
if (Constants.isIOS && enableBlur) {
192192
return {backgroundColor: Colors.rgba(backgroundColor, 0.85)};
@@ -308,7 +308,7 @@ function createStyles({width, height, borderRadius, selectionOptions}: CardProps
308308
},
309309
containerShadow: {
310310
// sh30 bottom
311-
shadowColor: Colors.grey40,
311+
shadowColor: Colors.$backgroundNeutralIdle,
312312
shadowOpacity: 0.25,
313313
shadowRadius: 12,
314314
shadowOffset: {height: 5, width: 0}

0 commit comments

Comments
 (0)