-
Notifications
You must be signed in to change notification settings - Fork 734
Infra/assets internal new structure #3635
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
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
627ecbb
Add internal assets module with icons and images
adids1221 09884c2
Refactor icon imports to use internal assets for consistency
adids1221 517b077
Refactor asset imports to use internal structure and remove assets.ic…
adids1221 2219ccb
Add xSmall icon and update ChipsInput to use internal assets
adids1221 bf5b253
Add transparentSwatch icon and update ColorSwatch component to use it
adids1221 9c59698
Add dropdown to icons and update useFieldType to utilize internal assets
adids1221 76d7e03
Add hintTip icons and update Hint component to use internal assets
adids1221 c25d1e5
Add checkMarkSmall and exclamationSmall icons, update WizardStates to…
adids1221 1224520
Add gradient overlay images and update Overlay component to use inter…
adids1221 5bac3cf
Add gradientOverlay image and update ScrollBar component to use it
adids1221 893c73e
move hint, swatch assets to internal.images
adids1221 656b0ac
Rename icons.dropdown to icons.chevronDown
adids1221 d9168a8
Add icons.demo and update references in components screens
adids1221 f5099c3
rename checkSmall icon file and update icons - index.js reference
adids1221 64e5930
Merge branch 'master' into infra/Assets_internal
adids1221 94b12f8
Update ColorSwatch to use internal.images for transparentSwatch
adids1221 9857ed7
Refactor icon and image exports to include URI and dimensions
adids1221 e8c0415
Refactor image handling to extract image source and apply dimensions …
adids1221 730a5c9
Update snapshots to reflect changes in image in Avatar, TextField, Bu…
adids1221 50761fa
remove unnecessary default export in check icon
adids1221 121d646
Add script to extract image dimensions and update package.json
adids1221 33629c6
Merge branch 'master' into infra/Assets_internal_new_strucure
adids1221 fde6928
Revert new structure, split into index.web filesÏ
adids1221 c7e17a0
Merge branch 'master' into infra/Assets_internal
adids1221 52fdada
Merge branch 'infra/Assets_internal' into infra/Assets_internal_new_s…
adids1221 c21c826
Icon remove DEFAULT_WEB_ICON_SIZE
adids1221 9aee276
Stepper local assets remove, move to Assets
adids1221 fd939f3
Merge branch 'infra/Assets_internal' into infra/Assets_internal_new_s…
adids1221 0c88600
Add new icon variants: minusOutline, minusOutlineSmall, plusOutline, …
adids1221 0caa8d2
Update asset imports to use .default for images and icons
adids1221 7dc1ac4
Remove esModule option from url-loader configuration in webpack
adids1221 267e930
Remove docuilib configurations from ReactLiveScope
adids1221 06f0d96
Bump version to 3.14.0 in package.json
adids1221 4d64cbf
Refactor icon asset loading to use the new web assets structure
adids1221 4adb167
Rename update-web-assets script to updateWebAssets in package.json
adids1221 34b9e07
changed extract-dimensions script to use console.error
adids1221 e81cd7e
Update file filtering in createIndexFile to exclude sized assets
adids1221 ae1eff4
rename extract-dimensions script
adids1221 58eb45c
Merge branch 'master' into infra/Assets_internal_new_strucure
adids1221 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
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) { | ||
// eslint-disable-next-line no-restricted-syntax | ||
console.error(`Error getting dimensions for ${imagePath}:`, sizeError); | ||
// Default dimensions if sizeOf fails | ||
return {width: 24, height: 24}; | ||
} | ||
} catch (error) { | ||
// eslint-disable-next-line no-restricted-syntax | ||
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('@')); | ||
|
||
let content = ''; | ||
|
||
if (fileType === 'icons') { | ||
content = 'export const icons = {\n'; | ||
} else if (fileType === 'images') { | ||
content = 'export const images = {\n'; | ||
} | ||
|
||
files.forEach((file, index) => { | ||
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`; | ||
// eslint-disable-next-line max-len | ||
content += ` return {uri: require('./${file}').default, width: ${dimensions.width}, height: ${dimensions.height}};\n`; | ||
content += index === files.length - 1 ? ` }\n` : ` },\n`; // Conditional check for the last file | ||
}); | ||
|
||
content += '};\n'; | ||
|
||
fs.writeFileSync(targetPath, content); | ||
console.log(`Created ${targetPath}`); | ||
} | ||
|
||
// Create index files | ||
createIndexFile(ICONS_PATH, path.join(ICONS_PATH, 'index.web.js'), 'icons'); | ||
createIndexFile(IMAGES_PATH, path.join(IMAGES_PATH, 'index.web.js'), 'images'); | ||
|
||
console.log('Index files created successfully!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
export const icons = { | ||
get check() { | ||
return {uri: require('./check.png').default, width: 21, height: 15}; | ||
}, | ||
get checkMarkSmall() { | ||
return {uri: require('./checkMarkSmall.png').default, width: 16, height: 16}; | ||
}, | ||
get checkSmall() { | ||
return {uri: require('./checkSmall.png').default, width: 24, height: 24}; | ||
}, | ||
get chevronDown() { | ||
return {uri: require('./chevronDown.png').default, width: 16, height: 16}; | ||
}, | ||
get exclamationSmall() { | ||
return {uri: require('./exclamationSmall.png').default, width: 16, height: 16}; | ||
}, | ||
get minusOutline() { | ||
return {uri: require('./minusOutline.png').default, width: 32, height: 32}; | ||
}, | ||
get minusOutlineSmall() { | ||
return {uri: require('./minusOutlineSmall.png').default, width: 24, height: 24}; | ||
}, | ||
get minusSmall() { | ||
return {uri: require('./minusSmall.png').default, width: 16, height: 16}; | ||
}, | ||
get plusOutline() { | ||
return {uri: require('./plusOutline.png').default, width: 32, height: 32}; | ||
}, | ||
get plusOutlineSmall() { | ||
return {uri: require('./plusOutlineSmall.png').default, width: 24, height: 24}; | ||
}, | ||
get plusSmall() { | ||
return {uri: require('./plusSmall.png').default, width: 16, height: 16}; | ||
}, | ||
get search() { | ||
return {uri: require('./search.png').default, width: 24, height: 24}; | ||
}, | ||
get x() { | ||
return {uri: require('./x.png').default, width: 17, height: 16}; | ||
}, | ||
get xFlat() { | ||
return {uri: require('./xFlat.png').default, width: 16, height: 16}; | ||
}, | ||
get xMedium() { | ||
return {uri: require('./xMedium.png').default, width: 24, height: 24}; | ||
}, | ||
get xSmall() { | ||
return {uri: require('./xSmall.png').default, width: 16, height: 16}; | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export const images = { | ||
get gradient() { | ||
return {uri: require('./gradient.png').default, width: 56, height: 2}; | ||
}, | ||
get gradientOverlay() { | ||
return {uri: require('./gradientOverlay.png').default, width: 76, height: 48}; | ||
}, | ||
get gradientOverlayHigh() { | ||
return {uri: require('./gradientOverlayHigh.png').default, width: 1, height: 297}; | ||
}, | ||
get gradientOverlayLow() { | ||
return {uri: require('./gradientOverlayLow.png').default, width: 1, height: 297}; | ||
}, | ||
get gradientOverlayMedium() { | ||
return {uri: require('./gradientOverlayMedium.png').default, width: 1, height: 297}; | ||
}, | ||
get hintTipMiddle() { | ||
return {uri: require('./hintTipMiddle.png').default, width: 20, height: 7}; | ||
}, | ||
get hintTipSide() { | ||
return {uri: require('./hintTipSide.png').default, width: 20, height: 24}; | ||
}, | ||
get transparentSwatch() { | ||
return {uri: require('./transparentSwatch.png').default, width: 100, height: 100}; | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.