Skip to content

Revert formatting changes in multiple components #3631

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

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 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
13a83a2
feat: Fix formatting issues, add image-size dependency and asset upda…
devin-ai-integration[bot] Mar 16, 2025
c737e5b
Image support in Assets web files
adids1221 Mar 16, 2025
0d3836d
feat: Add MIME type checking to extract-dimensions script
devin-ai-integration[bot] Mar 17, 2025
5f844b2
fix: Remove trailing commas from web index files
devin-ai-integration[bot] Mar 17, 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
c42ebaa
Merge remote-tracking branch 'origin/infra/Assets_internal' into feat…
devin-ai-integration[bot] Mar 17, 2025
c1adcef
fix: Update web index files to reference renamed and moved assets, ma…
devin-ai-integration[bot] Mar 17, 2025
fe5f534
refactor: Consolidate web and non-web index files to always include d…
devin-ai-integration[bot] Mar 18, 2025
175dfd8
refactor: Remove web-specific index files
devin-ai-integration[bot] Mar 18, 2025
3a0edfd
refactor: Update component references to use consolidated index files
devin-ai-integration[bot] Mar 18, 2025
236bf11
Revert formatting changes in multiple components
devin-ai-integration[bot] Mar 18, 2025
42964ea
Fix indentation in TextField driver spec file
devin-ai-integration[bot] Mar 18, 2025
480ce06
Fix formatting issues in multiple components
devin-ai-integration[bot] Mar 18, 2025
a2e2c27
Update internal assets index files
devin-ai-integration[bot] Mar 18, 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
10 changes: 10 additions & 0 deletions demo/src/screens/__tests__/__snapshots__/AvatarScreen.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ exports[`AvatarScreen renders screen 1`] = `
}
style={
[
false,
undefined,
undefined,
{
Expand Down Expand Up @@ -1194,6 +1195,7 @@ exports[`AvatarScreen renders screen 1`] = `
}
style={
[
false,
undefined,
undefined,
{
Expand Down Expand Up @@ -1465,6 +1467,7 @@ exports[`AvatarScreen renders screen 1`] = `
}
style={
[
false,
undefined,
undefined,
{
Expand Down Expand Up @@ -1659,6 +1662,7 @@ exports[`AvatarScreen renders screen 1`] = `
}
style={
[
false,
undefined,
undefined,
{
Expand Down Expand Up @@ -1916,6 +1920,7 @@ exports[`AvatarScreen renders screen 1`] = `
}
style={
[
false,
undefined,
undefined,
{
Expand Down Expand Up @@ -2046,6 +2051,7 @@ exports[`AvatarScreen renders screen 1`] = `
}
style={
[
false,
null,
undefined,
undefined,
Expand Down Expand Up @@ -2218,6 +2224,7 @@ exports[`AvatarScreen renders screen 1`] = `
}
style={
[
false,
undefined,
undefined,
{
Expand Down Expand Up @@ -2448,6 +2455,7 @@ exports[`AvatarScreen renders screen 1`] = `
}
style={
[
false,
undefined,
undefined,
{
Expand Down Expand Up @@ -2678,6 +2686,7 @@ exports[`AvatarScreen renders screen 1`] = `
}
style={
[
false,
undefined,
undefined,
{
Expand Down Expand Up @@ -2866,6 +2875,7 @@ exports[`AvatarScreen renders screen 1`] = `
}
style={
[
false,
undefined,
undefined,
{
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",
"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
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"url": "https://github.com/wix/react-native-ui-lib"
},
"scripts": {
"update-web-assets": "node scripts/assets/extract-dimensions.js",
"start": "watchman watch-del-all && react-native start",
"start:web": "npm --prefix webDemo run start",
"ios": "react-native run-ios",
Expand Down Expand Up @@ -83,6 +84,7 @@
"@types/hoist-non-react-statics": "^3.3.1",
"@types/jest": "^29.2.1",
"@types/lodash": "^4.0.0",
"@types/mime-types": "^2.1.4",
"@types/prop-types": "^15.5.3",
"@types/react": "18.3.7",
"@types/react-native": "0.73.0",
Expand All @@ -100,9 +102,11 @@
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.0.4",
"eslint-plugin-react-native": "^4.0.0",
"image-size": "^2.0.1",
"jest": "^29.6.3",
"light-date": "^1.2.0",
"metro-react-native-babel-preset": "0.73.10",
"mime-types": "^2.1.35",
"moment": "^2.24.0",
"object-hash": "^3.0.0",
"postcss": "^8.4.21",
Expand Down
85 changes: 85 additions & 0 deletions scripts/assets/extract-dimensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
const fs = require('fs');
const path = require('path');
const mime = require('mime-types');
const {imageSize: sizeOf} = require('image-size');

// Base paths
const ICONS_PATH = path.resolve(__dirname, '../../src/assets/internal/icons');
const IMAGES_PATH = path.resolve(__dirname, '../../src/assets/internal/images');

// Function to check if file is an image
function isImageFile(filePath) {
const mimeType = mime.lookup(filePath);
return !!mimeType && mimeType.includes('image');
}

// Function to get dimensions of an image
function getDimensions(imagePath) {
try {
if (!isImageFile(imagePath)) {
console.warn(`File is not an image: ${imagePath}`);
return {width: 0, height: 0};
}

try {
const buffer = fs.readFileSync(imagePath);
const dimensions = sizeOf(buffer);
return {
width: dimensions.width,
height: dimensions.height
};
} catch (sizeError) {
console.error(`Error getting dimensions for ${imagePath}:`, sizeError);
// Default dimensions if sizeOf fails
return {width: 24, height: 24};
}
} catch (error) {
console.error(`Error getting dimensions for ${imagePath}:`, error);
return {width: 0, height: 0};
}
}

// Function to create index files with dimensions
function createIndexFile(sourcePath, targetPath, fileType) {
const files = fs.readdirSync(sourcePath).filter(file => !file.includes('@') && !file.startsWith('.'));

let content = '';

if (fileType === 'icons') {
content = 'export const icons = {\n';
} else if (fileType === 'images') {
content = 'export const images = {\n';
}

files.forEach(file => {
const filePath = path.join(sourcePath, file);
const mimeType = mime.lookup(filePath);
const isImage = !!mimeType && mimeType.includes('image');

if (!isImage) {
console.warn(`Skipping non-image file: ${filePath}`);
return;
}

const name = path.basename(file, path.extname(file));
const dimensions = getDimensions(filePath);

// Handle hyphenated filenames by converting to camelCase
const propertyName = name.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase());

content += ` get ${propertyName}() {\n`;
content += ` return {uri: require('./${file}'), dimensions: {width: ${dimensions.width}, height: ${dimensions.height}}};\n`;
content += ` },\n`;
});

content += '};\n';

fs.writeFileSync(targetPath, content);
console.log(`Created ${targetPath}`);
}

// Create index files
createIndexFile(ICONS_PATH, path.join(ICONS_PATH, 'index.ts'), 'icons');
createIndexFile(IMAGES_PATH, path.join(IMAGES_PATH, 'index.ts'), 'images');

console.log('Index files created successfully!');
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.
Loading