Skip to content

Infra/assets internal #3618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
627ecbb
Add internal assets module with icons and images
adids1221 Mar 16, 2025
09884c2
Refactor icon imports to use internal assets for consistency
adids1221 Mar 16, 2025
517b077
Refactor asset imports to use internal structure and remove assets.ic…
adids1221 Mar 16, 2025
2219ccb
Add xSmall icon and update ChipsInput to use internal assets
adids1221 Mar 16, 2025
bf5b253
Add transparentSwatch icon and update ColorSwatch component to use it
adids1221 Mar 16, 2025
9c59698
Add dropdown to icons and update useFieldType to utilize internal assets
adids1221 Mar 16, 2025
76d7e03
Add hintTip icons and update Hint component to use internal assets
adids1221 Mar 16, 2025
c25d1e5
Add checkMarkSmall and exclamationSmall icons, update WizardStates to…
adids1221 Mar 16, 2025
1224520
Add gradient overlay images and update Overlay component to use inter…
adids1221 Mar 16, 2025
5bac3cf
Add gradientOverlay image and update ScrollBar component to use it
adids1221 Mar 16, 2025
893c73e
move hint, swatch assets to internal.images
adids1221 Mar 17, 2025
656b0ac
Rename icons.dropdown to icons.chevronDown
adids1221 Mar 17, 2025
d9168a8
Add icons.demo and update references in components screens
adids1221 Mar 17, 2025
f5099c3
rename checkSmall icon file and update icons - index.js reference
adids1221 Mar 17, 2025
64e5930
Merge branch 'master' into infra/Assets_internal
adids1221 Mar 17, 2025
94b12f8
Update ColorSwatch to use internal.images for transparentSwatch
adids1221 Mar 18, 2025
c7e17a0
Merge branch 'master' into infra/Assets_internal
adids1221 Mar 19, 2025
9aee276
Stepper local assets remove, move to Assets
adids1221 Mar 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes
File renamed without changes
File renamed without changes
5 changes: 4 additions & 1 deletion demo/src/configurations.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export const loadDemoConfigurations = () => {
settings: require('./assets/icons/settings.png'),
share: require('./assets/icons/share.png'),
info: require('./assets/icons/info.png'),
exclamation: require('./assets/icons/exclamationFillSmall.png')
exclamation: require('./assets/icons/exclamationFillSmall.png'),
check: require('./assets/icons/check.png'),
x: require('./assets/icons/x.png'),
minus: require('./assets/icons/minusSmall.png')
});

Assets.loadAssetsGroup('images.demo', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3933,7 +3933,7 @@ exports[`TextField Screen renders screen 1`] = `
accessible={false}
source={
{
"testUri": "../../../src/assets/icons/xFlat.png",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should move the snap tests to the component's dir, they shouldn't be in the demo

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then you'll be referencing the demo from the src code
Also, focus on the assets change, if you decide to do other changes, do it in another PR please

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we do it already in other snaps and in private as well. I think we better keep tests in src instead of the demo

"testUri": "../../../src/assets/internal/icons/xFlat.png",
}
}
style={
Expand Down
2 changes: 1 addition & 1 deletion demo/src/screens/componentScreens/CheckboxScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class CheckboxScreen extends Component {
borderRadius={2}
size={30}
color={Colors.purple30}
selectedIcon={Assets.icons.x}
selectedIcon={Assets.icons.demo.x}
marginL-s5
/>

Expand Down
2 changes: 1 addition & 1 deletion demo/src/screens/componentScreens/IconScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const IconScreen = () => {
<Icon
size={customSize ? size : undefined}
tintColor={customColor ? (color as string) : undefined}
source={Assets.icons.search}
source={Assets.icons.demo.search}
badgeProps={
useBadge
? {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/screens/componentScreens/ModalScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default class ModalScreen extends Component<ModalScreenProps, State> {
]}
leftButtons={[
{
icon: Assets.icons.x,
icon: Assets.icons.demo.x,
onPress: () => Alert.alert('back'),
buttonProps: {hitSlop: BUTTONS_HIT_SLOP, iconStyle: {tintColor: Colors.yellow10}}
}
Expand Down
2 changes: 1 addition & 1 deletion demo/src/screens/componentScreens/PickerScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const renderContact = (contactValue: any, props: any) => {
{contact?.name}
</Text>
</View>
{props.isSelected && <Icon source={Assets.icons.check} tintColor={Colors.$iconDefault}/>}
{props.isSelected && <Icon source={Assets.icons.demo.check} tintColor={Colors.$iconDefault}/>}
</View>
);
};
Expand Down
4 changes: 2 additions & 2 deletions demo/src/screens/componentScreens/RadioButtonScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export default class RadioButtonScreen extends Component {
Yes or No?
</Text>
<View row>
{this.renderRadioButtonWithImage('yes', Assets.icons.check, {tintColor: 'green'})}
{this.renderRadioButtonWithImage('no', Assets.icons.x, {tintColor: 'red'})}
{this.renderRadioButtonWithImage('yes', Assets.icons.demo.check, {tintColor: 'green'})}
{this.renderRadioButtonWithImage('no', Assets.icons.demo.x, {tintColor: 'red'})}
</View>
<Text marginT-10>You chose: {this.state.value}</Text>
</RadioGroup>
Expand Down
24 changes: 20 additions & 4 deletions demo/src/screens/componentScreens/SegmentedControlScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import React, {useCallback, useState} from 'react';
import {StyleSheet} from 'react-native';
import {Text, View, Colors, SegmentedControl, Assets, Spacings, BorderRadiuses, Typography, SegmentedControlItemProps} from 'react-native-ui-lib';
import {
Text,
View,
Colors,
SegmentedControl,
Assets,
Spacings,
BorderRadiuses,
Typography,
SegmentedControlItemProps
} from 'react-native-ui-lib';

const segments: Record<string, Array<SegmentedControlItemProps>> = {
first: [{label: 'Default'}, {label: 'Form'}],
second: [{label: '1'}, {label: '2'}, {label: '3'}, {label: Assets.emojis.airplane}, {label: '5'}],
third: [
{
label: 'Very Long Label with icon',
iconSource: Assets.icons.search,
iconSource: Assets.icons.demo.search,
iconStyle: {marginLeft: Spacings.s1, width: 16, height: 16},
iconOnRight: true
},
Expand All @@ -18,7 +28,11 @@ const segments: Record<string, Array<SegmentedControlItemProps>> = {
fifth: [{label: 'Full'}, {label: 'Width'}],
sixth: [{label: 'Full'}, {label: 'Width'}, {label: 'With'}, {label: 'A'}, {label: 'Very Long Segment'}],
seventh: [{label: '$'}, {label: '%'}],
eighth: [{label: 'Plus', iconSource: Assets.icons.plusSmall}, {label: 'Minus', iconSource: Assets.icons.minusSmall}, {label: 'Check', iconSource: Assets.icons.checkSmall}],
eighth: [
{label: 'Plus', iconSource: Assets.icons.demo.plus},
{label: 'Minus', iconSource: Assets.icons.demo.minus},
{label: 'Check', iconSource: Assets.icons.demo.check}
],
ninth: [{label: 'with'}, {label: 'a'}, {label: 'label'}]
};

Expand Down Expand Up @@ -72,7 +86,9 @@ const SegmentedControlScreen = () => {
segmentLabelStyle={styles.customTypography}
preset={screenPreset}
/>
<Text center marginT-s4>With Icons</Text>
<Text center marginT-s4>
With Icons
</Text>
<SegmentedControl segments={segments.eighth} preset={screenPreset}/>
<Text marginT-s4 center>
Custom Styling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Tab1 extends Component {
round
style={{width: 50}}
size={Button.sizes.small}
iconSource={Assets.icons.search}
iconSource={Assets.icons.demo.search}
white
/>
</View>
Expand Down
2 changes: 1 addition & 1 deletion demo/src/screens/componentScreens/ToastsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default class ToastsScreen extends Component {
onDismiss={this.dismissTopToast}
// autoDismiss={3000}
showDismiss={showDismiss}
// action={{iconSource: Assets.icons.x, onPress: () => console.log('dismiss')}}
// action={{iconSource: Assets.icons.demo.x, onPress: () => console.log('dismiss')}}
showLoader={showLoader}
/>
<Toast
Expand Down
2 changes: 1 addition & 1 deletion demo/src/screens/realExamples/ListActions/ActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default class ActionsList extends Component {
size={'xSmall'}
round
backgroundColor="transparent"
iconSource={Assets.icons.x}
iconSource={Assets.icons.demo.x}
iconStyle={{tintColor: Colors.white}}
onPress={() => {
// console.warn('dismiss press');
Expand Down
2 changes: 1 addition & 1 deletion expoDemo/MainScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default function MainScreen({navigation}) {
preset={null}
text70
fieldStyle={styles.fieldStyle}
leadingAccessory={<Icon source={Assets.icons.search} marginH-s2/>}
leadingAccessory={<Icon source={Assets.internal.icons.search} marginH-s2/>}
/>
}
sections={sections}
Expand Down
26 changes: 0 additions & 26 deletions src/assets/icons/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/assets/images/index.js

This file was deleted.

7 changes: 2 additions & 5 deletions src/assets/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {Assets} from './Assets';

export default new Assets().loadAssetsGroup('', {
get icons() {
return require('./icons').icons;
},
get emojis() {
return require('./emojis').emojis;
},
get images() {
return require('./images').images;
get internal() {
return require('./internal').internal;
}
});
Binary file added src/assets/internal/icons/check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/internal/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/internal/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/internal/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/internal/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions src/assets/internal/icons/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export const icons = {
get check() {
return require('./check.png');
},
get checkMarkSmall() {
return require('./checkMarkSmall.png');
},
get checkSmall() {
return require('./checkSmall.png');
},
get chevronDown() {
return require('./chevronDown.png');
},
get exclamationSmall() {
return require('./exclamationSmall.png');
},
get minusOutline() {
return require('./minusOutline.png');
},
get minusOutlineSmall() {
return require('./minusOutlineSmall.png');
},
get minusSmall() {
return require('./minusSmall.png');
},
get plusOutline() {
return require('./plusOutline.png');
},
get plusOutlineSmall() {
return require('./plusOutlineSmall.png');
},
get plusSmall() {
return require('./plusSmall.png');
},
get search() {
return require('./search.png');
},
get x() {
return require('./x.png');
},
get xFlat() {
return require('./xFlat.png');
},
get xMedium() {
return require('./xMedium.png');
},
get xSmall() {
return require('./xSmall.png');
}
};
Binary file added src/assets/internal/icons/minusSmall.png
Binary file added src/assets/internal/icons/[email protected]
Binary file added src/assets/internal/icons/[email protected]
Binary file added src/assets/internal/icons/[email protected]
Binary file added src/assets/internal/icons/[email protected]
File renamed without changes
Binary file added src/assets/internal/icons/x.png
Binary file added src/assets/internal/icons/[email protected]
Binary file added src/assets/internal/icons/[email protected]
File renamed without changes
File renamed without changes
File renamed without changes
26 changes: 26 additions & 0 deletions src/assets/internal/images/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export const images = {
get gradient() {
return require('./gradient.png');
},
get gradientOverlay() {
return require('./gradientOverlay.png');
},
get gradientOverlayHigh() {
return require('./gradientOverlayHigh.png');
},
get gradientOverlayLow() {
return require('./gradientOverlayLow.png');
},
get gradientOverlayMedium() {
return require('./gradientOverlayMedium.png');
},
get hintTipMiddle() {
return require('./hintTipMiddle.png');
},
get hintTipSide() {
return require('./hintTipSide.png');
},
get transparentSwatch() {
return require('./transparentSwatch.png');
}
};
8 changes: 8 additions & 0 deletions src/assets/internal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const internal = {
get icons() {
return require('./icons').icons;
},
get images() {
return require('./images').images;
}
};
2 changes: 1 addition & 1 deletion src/components/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const DEFAULT_SELECTION_PROPS = {
borderWidth: 2,
color: Colors.$backgroundPrimaryHeavy,
indicatorSize: 20,
icon: Assets.icons.checkSmall,
icon: Assets.internal.icons.checkSmall,
iconColor: Colors.$iconDefaultLight,
hideIndicator: false
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
>
<AnimatedIcon
style={[this.styles.selectedIcon, {transform: this.animationStyle.transform}]}
source={indeterminate ? Assets.icons.minusSmall : selectedIcon || Assets.icons.checkSmall}
source={indeterminate ? Assets.internal.icons.minusSmall : selectedIcon || Assets.internal.icons.checkSmall}
testID={`${testID}.selected`}
tintColor={this.getTintColor()}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/chip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const Chip = ({
containerStyle,
onDismiss,
dismissColor = Colors.$iconDefault,
dismissIcon = Assets.icons.x,
dismissIcon = Assets.internal.icons.x,
dismissIconStyle,
dismissContainerStyle,
iconProps,
Expand Down
5 changes: 2 additions & 3 deletions src/components/chipsInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import {isUndefined, map} from 'lodash';
import {Constants} from '../../commons/new';
import {useCombinedRefs, useDidUpdate} from '../../hooks';
import TextField, {TextFieldProps} from '../textField';
import Assets from '../../assets';
import Chip, {ChipProps} from '../chip';

const removeIcon = require('./assets/xSmall.png');

export enum ChipsInputChangeReason {
Added = 'added',
Removed = 'removed'
Expand Down Expand Up @@ -122,7 +121,7 @@ const ChipsInput = forwardRef((props: ChipsInputProps, refToForward: React.Ref<a
// paddingH-s2
marginR-s2
marginB-s2
dismissIcon={removeIcon}
dismissIcon={Assets.internal.icons.xSmall}
recorderTag={'mask'}
{...defaultChipProps}
{...(chip.invalid ? invalidChipProps : undefined)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/colorPicker/ColorPickerDialogHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ColorPickerDialogHeader = (props: HeaderProps) => {
<View row spread bg-$backgroundDefault paddingH-20 style={styles.header}>
<Button
link
iconSource={Assets.icons.x}
iconSource={Assets.internal.icons.x}
iconStyle={{tintColor: Colors.$iconDefault}}
onPress={onDismiss}
accessibilityLabel={_.get(accessibilityLabels, 'dismissButton')}
Expand All @@ -32,7 +32,7 @@ const ColorPickerDialogHeader = (props: HeaderProps) => {
color={doneButtonColor}
disabled={!valid}
link
iconSource={Assets.icons.check}
iconSource={Assets.internal.icons.check}
onPress={onDonePressed}
accessibilityLabel={_.get(accessibilityLabels, 'doneButton')}
testID={`${testID}.dialog.done`}
Expand Down
2 changes: 1 addition & 1 deletion src/components/colorPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const ColorPicker = (props: Props) => {
style={styles.button}
round
outline
iconSource={Assets.icons.plusSmall}
iconSource={Assets.internal.icons.plusSmall}
onPress={showDialog}
testID={`${testID}-button`}
accessibilityLabel={accessibilityLabels?.addButton}
Expand Down
9 changes: 6 additions & 3 deletions src/components/colorSwatch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ interface Props {
}
export type ColorSwatchProps = Props & ColorsModifiers;

const transparentImage = require('./assets/transparentSwatch/TransparentSwatch.png');
const DEFAULT_SIZE = Constants.isTablet ? 44 : 36;
export const SWATCH_MARGIN = 12;
export const SWATCH_SIZE = DEFAULT_SIZE;
Expand Down Expand Up @@ -178,13 +177,17 @@ class ColorSwatch extends PureComponent<Props & BaseComponentInjectedProps> {
{...this.getAccessibilityInfo()}
>
{Colors.isTransparent(this.color) && (
<Image source={transparentImage} style={this.styles.transparentImage} resizeMode={'cover'}/>
<Image
source={Assets.internal.images.transparentSwatch}
style={this.styles.transparentImage}
resizeMode={'cover'}
/>
)}
{unavailable ? (
<View style={[this.styles.unavailable, {backgroundColor: tintColor}]}/>
) : (
<Animated.Image
source={Assets.icons.check}
source={Assets.internal.icons.check}
style={{
tintColor,
opacity: isSelected,
Expand Down
Loading