Skip to content

Commit 6c7f5b3

Browse files
authored
Infra/assets internal (#3618)
* Add internal assets module with icons and images * Refactor icon imports to use internal assets for consistency * Refactor asset imports to use internal structure and remove assets.icons/images * Add xSmall icon and update ChipsInput to use internal assets * Add transparentSwatch icon and update ColorSwatch component to use it * Add dropdown to icons and update useFieldType to utilize internal assets * Add hintTip icons and update Hint component to use internal assets * Add checkMarkSmall and exclamationSmall icons, update WizardStates to use internal assets * Add gradient overlay images and update Overlay component to use internal assets * Add gradientOverlay image and update ScrollBar component to use it * move hint, swatch assets to internal.images * Rename icons.dropdown to icons.chevronDown * Add icons.demo and update references in components screens * rename checkSmall icon file and update icons - index.js reference * Update ColorSwatch to use internal.images for transparentSwatch * Stepper local assets remove, move to Assets
1 parent 4b34f8f commit 6c7f5b3

File tree

179 files changed

+188
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+188
-123
lines changed
File renamed without changes.
File renamed without changes.

demo/src/configurations.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export const loadDemoConfigurations = () => {
1616
settings: require('./assets/icons/settings.png'),
1717
share: require('./assets/icons/share.png'),
1818
info: require('./assets/icons/info.png'),
19-
exclamation: require('./assets/icons/exclamationFillSmall.png')
19+
exclamation: require('./assets/icons/exclamationFillSmall.png'),
20+
check: require('./assets/icons/check.png'),
21+
x: require('./assets/icons/x.png'),
22+
minus: require('./assets/icons/minusSmall.png')
2023
});
2124

2225
Assets.loadAssetsGroup('images.demo', {

demo/src/screens/__tests__/__snapshots__/TextFieldScreen.spec.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3933,7 +3933,7 @@ exports[`TextField Screen renders screen 1`] = `
39333933
accessible={false}
39343934
source={
39353935
{
3936-
"testUri": "../../../src/assets/icons/xFlat.png",
3936+
"testUri": "../../../src/assets/internal/icons/xFlat.png",
39373937
}
39383938
}
39393939
style={

demo/src/screens/componentScreens/CheckboxScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class CheckboxScreen extends Component {
5151
borderRadius={2}
5252
size={30}
5353
color={Colors.purple30}
54-
selectedIcon={Assets.icons.x}
54+
selectedIcon={Assets.icons.demo.x}
5555
marginL-s5
5656
/>
5757

demo/src/screens/componentScreens/IconScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const IconScreen = () => {
2424
<Icon
2525
size={customSize ? size : undefined}
2626
tintColor={customColor ? (color as string) : undefined}
27-
source={Assets.icons.search}
27+
source={Assets.icons.demo.search}
2828
badgeProps={
2929
useBadge
3030
? {

demo/src/screens/componentScreens/ModalScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default class ModalScreen extends Component<ModalScreenProps, State> {
123123
]}
124124
leftButtons={[
125125
{
126-
icon: Assets.icons.x,
126+
icon: Assets.icons.demo.x,
127127
onPress: () => Alert.alert('back'),
128128
buttonProps: {hitSlop: BUTTONS_HIT_SLOP, iconStyle: {tintColor: Colors.yellow10}}
129129
}

demo/src/screens/componentScreens/PickerScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const renderContact = (contactValue: any, props: any) => {
4444
{contact?.name}
4545
</Text>
4646
</View>
47-
{props.isSelected && <Icon source={Assets.icons.check} tintColor={Colors.$iconDefault}/>}
47+
{props.isSelected && <Icon source={Assets.icons.demo.check} tintColor={Colors.$iconDefault}/>}
4848
</View>
4949
);
5050
};

demo/src/screens/componentScreens/RadioButtonScreen.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ export default class RadioButtonScreen extends Component {
102102
Yes or No?
103103
</Text>
104104
<View row>
105-
{this.renderRadioButtonWithImage('yes', Assets.icons.check, {tintColor: 'green'})}
106-
{this.renderRadioButtonWithImage('no', Assets.icons.x, {tintColor: 'red'})}
105+
{this.renderRadioButtonWithImage('yes', Assets.icons.demo.check, {tintColor: 'green'})}
106+
{this.renderRadioButtonWithImage('no', Assets.icons.demo.x, {tintColor: 'red'})}
107107
</View>
108108
<Text marginT-10>You chose: {this.state.value}</Text>
109109
</RadioGroup>

demo/src/screens/componentScreens/SegmentedControlScreen.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import React, {useCallback, useState} from 'react';
22
import {StyleSheet} from 'react-native';
3-
import {Text, View, Colors, SegmentedControl, Assets, Spacings, BorderRadiuses, Typography, SegmentedControlItemProps} from 'react-native-ui-lib';
3+
import {
4+
Text,
5+
View,
6+
Colors,
7+
SegmentedControl,
8+
Assets,
9+
Spacings,
10+
BorderRadiuses,
11+
Typography,
12+
SegmentedControlItemProps
13+
} from 'react-native-ui-lib';
414

515
const segments: Record<string, Array<SegmentedControlItemProps>> = {
616
first: [{label: 'Default'}, {label: 'Form'}],
717
second: [{label: '1'}, {label: '2'}, {label: '3'}, {label: Assets.emojis.airplane}, {label: '5'}],
818
third: [
919
{
1020
label: 'Very Long Label with icon',
11-
iconSource: Assets.icons.search,
21+
iconSource: Assets.icons.demo.search,
1222
iconStyle: {marginLeft: Spacings.s1, width: 16, height: 16},
1323
iconOnRight: true
1424
},
@@ -18,7 +28,11 @@ const segments: Record<string, Array<SegmentedControlItemProps>> = {
1828
fifth: [{label: 'Full'}, {label: 'Width'}],
1929
sixth: [{label: 'Full'}, {label: 'Width'}, {label: 'With'}, {label: 'A'}, {label: 'Very Long Segment'}],
2030
seventh: [{label: '$'}, {label: '%'}],
21-
eighth: [{label: 'Plus', iconSource: Assets.icons.plusSmall}, {label: 'Minus', iconSource: Assets.icons.minusSmall}, {label: 'Check', iconSource: Assets.icons.checkSmall}],
31+
eighth: [
32+
{label: 'Plus', iconSource: Assets.icons.demo.plus},
33+
{label: 'Minus', iconSource: Assets.icons.demo.minus},
34+
{label: 'Check', iconSource: Assets.icons.demo.check}
35+
],
2236
ninth: [{label: 'with'}, {label: 'a'}, {label: 'label'}]
2337
};
2438

@@ -72,7 +86,9 @@ const SegmentedControlScreen = () => {
7286
segmentLabelStyle={styles.customTypography}
7387
preset={screenPreset}
7488
/>
75-
<Text center marginT-s4>With Icons</Text>
89+
<Text center marginT-s4>
90+
With Icons
91+
</Text>
7692
<SegmentedControl segments={segments.eighth} preset={screenPreset}/>
7793
<Text marginT-s4 center>
7894
Custom Styling

demo/src/screens/componentScreens/TabControllerScreen/tab1.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Tab1 extends Component {
2424
round
2525
style={{width: 50}}
2626
size={Button.sizes.small}
27-
iconSource={Assets.icons.search}
27+
iconSource={Assets.icons.demo.search}
2828
white
2929
/>
3030
</View>

demo/src/screens/componentScreens/ToastsScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default class ToastsScreen extends Component {
108108
onDismiss={this.dismissTopToast}
109109
// autoDismiss={3000}
110110
showDismiss={showDismiss}
111-
// action={{iconSource: Assets.icons.x, onPress: () => console.log('dismiss')}}
111+
// action={{iconSource: Assets.icons.demo.x, onPress: () => console.log('dismiss')}}
112112
showLoader={showLoader}
113113
/>
114114
<Toast

demo/src/screens/realExamples/ListActions/ActionsList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export default class ActionsList extends Component {
197197
size={'xSmall'}
198198
round
199199
backgroundColor="transparent"
200-
iconSource={Assets.icons.x}
200+
iconSource={Assets.icons.demo.x}
201201
iconStyle={{tintColor: Colors.white}}
202202
onPress={() => {
203203
// console.warn('dismiss press');

expoDemo/MainScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default function MainScreen({navigation}) {
8383
preset={null}
8484
text70
8585
fieldStyle={styles.fieldStyle}
86-
leadingAccessory={<Icon source={Assets.icons.search} marginH-s2/>}
86+
leadingAccessory={<Icon source={Assets.internal.icons.search} marginH-s2/>}
8787
/>
8888
}
8989
sections={sections}

src/assets/icons/index.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/assets/images/index.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/assets/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import {Assets} from './Assets';
22

33
export default new Assets().loadAssetsGroup('', {
4-
get icons() {
5-
return require('./icons').icons;
6-
},
74
get emojis() {
85
return require('./emojis').emojis;
96
},
10-
get images() {
11-
return require('./images').images;
7+
get internal() {
8+
return require('./internal').internal;
129
}
1310
});

src/assets/internal/icons/check.png

190 Bytes
230 Bytes
270 Bytes
320 Bytes
358 Bytes

src/assets/internal/icons/index.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
export const icons = {
2+
get check() {
3+
return require('./check.png');
4+
},
5+
get checkMarkSmall() {
6+
return require('./checkMarkSmall.png');
7+
},
8+
get checkSmall() {
9+
return require('./checkSmall.png');
10+
},
11+
get chevronDown() {
12+
return require('./chevronDown.png');
13+
},
14+
get exclamationSmall() {
15+
return require('./exclamationSmall.png');
16+
},
17+
get minusOutline() {
18+
return require('./minusOutline.png');
19+
},
20+
get minusOutlineSmall() {
21+
return require('./minusOutlineSmall.png');
22+
},
23+
get minusSmall() {
24+
return require('./minusSmall.png');
25+
},
26+
get plusOutline() {
27+
return require('./plusOutline.png');
28+
},
29+
get plusOutlineSmall() {
30+
return require('./plusOutlineSmall.png');
31+
},
32+
get plusSmall() {
33+
return require('./plusSmall.png');
34+
},
35+
get search() {
36+
return require('./search.png');
37+
},
38+
get x() {
39+
return require('./x.png');
40+
},
41+
get xFlat() {
42+
return require('./xFlat.png');
43+
},
44+
get xMedium() {
45+
return require('./xMedium.png');
46+
},
47+
get xSmall() {
48+
return require('./xSmall.png');
49+
}
50+
};
159 Bytes
181 Bytes
214 Bytes
265 Bytes
288 Bytes
File renamed without changes.

src/assets/internal/icons/x.png

215 Bytes
277 Bytes
364 Bytes
File renamed without changes.
File renamed without changes.

src/assets/internal/images/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export const images = {
2+
get gradient() {
3+
return require('./gradient.png');
4+
},
5+
get gradientOverlay() {
6+
return require('./gradientOverlay.png');
7+
},
8+
get gradientOverlayHigh() {
9+
return require('./gradientOverlayHigh.png');
10+
},
11+
get gradientOverlayLow() {
12+
return require('./gradientOverlayLow.png');
13+
},
14+
get gradientOverlayMedium() {
15+
return require('./gradientOverlayMedium.png');
16+
},
17+
get hintTipMiddle() {
18+
return require('./hintTipMiddle.png');
19+
},
20+
get hintTipSide() {
21+
return require('./hintTipSide.png');
22+
},
23+
get transparentSwatch() {
24+
return require('./transparentSwatch.png');
25+
}
26+
};

src/assets/internal/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const internal = {
2+
get icons() {
3+
return require('./icons').icons;
4+
},
5+
get images() {
6+
return require('./images').images;
7+
}
8+
};

src/components/card/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const DEFAULT_SELECTION_PROPS = {
2323
borderWidth: 2,
2424
color: Colors.$backgroundPrimaryHeavy,
2525
indicatorSize: 20,
26-
icon: Assets.icons.checkSmall,
26+
icon: Assets.internal.icons.checkSmall,
2727
iconColor: Colors.$iconDefaultLight,
2828
hideIndicator: false
2929
};

src/components/checkbox/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
280280
>
281281
<AnimatedIcon
282282
style={[this.styles.selectedIcon, {transform: this.animationStyle.transform}]}
283-
source={indeterminate ? Assets.icons.minusSmall : selectedIcon || Assets.icons.checkSmall}
283+
source={indeterminate ? Assets.internal.icons.minusSmall : selectedIcon || Assets.internal.icons.checkSmall}
284284
testID={`${testID}.selected`}
285285
tintColor={this.getTintColor()}
286286
/>

src/components/chip/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const Chip = ({
146146
containerStyle,
147147
onDismiss,
148148
dismissColor = Colors.$iconDefault,
149-
dismissIcon = Assets.icons.x,
149+
dismissIcon = Assets.internal.icons.x,
150150
dismissIconStyle,
151151
dismissContainerStyle,
152152
iconProps,

src/components/chipsInput/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import {isUndefined, map} from 'lodash';
44
import {Constants} from '../../commons/new';
55
import {useCombinedRefs, useDidUpdate} from '../../hooks';
66
import TextField, {TextFieldProps} from '../textField';
7+
import Assets from '../../assets';
78
import Chip, {ChipProps} from '../chip';
89

9-
const removeIcon = require('./assets/xSmall.png');
10-
1110
export enum ChipsInputChangeReason {
1211
Added = 'added',
1312
Removed = 'removed'
@@ -122,7 +121,7 @@ const ChipsInput = forwardRef((props: ChipsInputProps, refToForward: React.Ref<a
122121
// paddingH-s2
123122
marginR-s2
124123
marginB-s2
125-
dismissIcon={removeIcon}
124+
dismissIcon={Assets.internal.icons.xSmall}
126125
recorderTag={'mask'}
127126
{...defaultChipProps}
128127
{...(chip.invalid ? invalidChipProps : undefined)}

src/components/colorPicker/ColorPickerDialogHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const ColorPickerDialogHeader = (props: HeaderProps) => {
2222
<View row spread bg-$backgroundDefault paddingH-20 style={styles.header}>
2323
<Button
2424
link
25-
iconSource={Assets.icons.x}
25+
iconSource={Assets.internal.icons.x}
2626
iconStyle={{tintColor: Colors.$iconDefault}}
2727
onPress={onDismiss}
2828
accessibilityLabel={_.get(accessibilityLabels, 'dismissButton')}
@@ -32,7 +32,7 @@ const ColorPickerDialogHeader = (props: HeaderProps) => {
3232
color={doneButtonColor}
3333
disabled={!valid}
3434
link
35-
iconSource={Assets.icons.check}
35+
iconSource={Assets.internal.icons.check}
3636
onPress={onDonePressed}
3737
accessibilityLabel={_.get(accessibilityLabels, 'doneButton')}
3838
testID={`${testID}.dialog.done`}

src/components/colorPicker/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const ColorPicker = (props: Props) => {
9595
style={styles.button}
9696
round
9797
outline
98-
iconSource={Assets.icons.plusSmall}
98+
iconSource={Assets.internal.icons.plusSmall}
9999
onPress={showDialog}
100100
testID={`${testID}-button`}
101101
accessibilityLabel={accessibilityLabels?.addButton}

src/components/colorSwatch/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ interface Props {
5252
}
5353
export type ColorSwatchProps = Props & ColorsModifiers;
5454

55-
const transparentImage = require('./assets/transparentSwatch/TransparentSwatch.png');
5655
const DEFAULT_SIZE = Constants.isTablet ? 44 : 36;
5756
export const SWATCH_MARGIN = 12;
5857
export const SWATCH_SIZE = DEFAULT_SIZE;
@@ -178,13 +177,17 @@ class ColorSwatch extends PureComponent<Props & BaseComponentInjectedProps> {
178177
{...this.getAccessibilityInfo()}
179178
>
180179
{Colors.isTransparent(this.color) && (
181-
<Image source={transparentImage} style={this.styles.transparentImage} resizeMode={'cover'}/>
180+
<Image
181+
source={Assets.internal.images.transparentSwatch}
182+
style={this.styles.transparentImage}
183+
resizeMode={'cover'}
184+
/>
182185
)}
183186
{unavailable ? (
184187
<View style={[this.styles.unavailable, {backgroundColor: tintColor}]}/>
185188
) : (
186189
<Animated.Image
187-
source={Assets.icons.check}
190+
source={Assets.internal.icons.check}
188191
style={{
189192
tintColor,
190193
opacity: isSelected,

0 commit comments

Comments
 (0)