-
Notifications
You must be signed in to change notification settings - Fork 107
Spinner refactor #2238
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
base: v12
Are you sure you want to change the base?
Spinner refactor #2238
Conversation
|
|
||
| function bootstrap() { | ||
| execSync(path.resolve('scripts/clean.js'), opts) |
Check warning
Code scanning / CodeQL
Shell command built from environment values
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
The fix is to avoid executing arbitrary shell commands built from dynamic path values via execSync. Instead, launch Node directly on the target script using execFileSync, passing the script path as an argument — this prevents shell expansion issues, avoids interpretation of spaces and special shell characters, and aligns with best practices. Specifically:
-
On line 68, in the
bootstrapfunction, replaceexecSync(path.resolve('scripts/clean.js'), opts)withexecFileSync(process.execPath, [path.resolve('scripts/clean.js')], opts). This runs the script under the Node interpreter rather than launching the script itself as a shell command. -
Import
execFileSyncfromchild_process. -
Optionally remove unused imports if needed (keep other code unchanged).
All changes are limited to the shown code in scripts/bootstrap.js.
-
Copy modified line R27 -
Copy modified line R68
| @@ -24,7 +24,7 @@ | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
| const { execSync, fork } = require('child_process') | ||
| const { execSync, execFileSync, fork } = require('child_process') | ||
| const path = require('path') | ||
|
|
||
| const opts = { stdio: 'inherit' } | ||
| @@ -65,7 +65,7 @@ | ||
| } | ||
|
|
||
| function bootstrap() { | ||
| execSync(path.resolve('scripts/clean.js'), opts) | ||
| execFileSync(process.execPath, [path.resolve('scripts/clean.js')], opts) | ||
| buildProject() | ||
| } | ||
|
|
|
|
|
||
| const styles = useStyle({ | ||
| generateStyle, | ||
| generateComponentTheme, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can delete this line (and generateComponentTheme.ts too)
matyasf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comments
| /** | ||
| * Render Spinner "as" another HTML element | ||
| */ | ||
| as?: AsElementType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this is a breaking change, please put it into the upgrade guide
| * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`, | ||
| * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via | ||
| * familiar CSS-like shorthand. For example: `margin="small auto large"`. | ||
| * Valid values are from themes. See theme.semantics.spacing. Apply these values via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is theme specific, right? theme.semantics.spacing is not guaranteed to be this path, I'd rephrase it to "See "See theme.sharedTokens.spacing
| <Spinner renderTitle="Loading" size="small" margin="0 0 0 medium" /> | ||
| <Spinner renderTitle="Loading" margin="0 0 0 medium" /> | ||
| <Spinner renderTitle="Loading" size="large" margin="0 0 0 medium" /> | ||
| <div style={{ display: 'flex', alignItems: 'center', gap: 'spacing.spaceMd' }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cant use spacing.spaceMd here
| type StyleParams = { | ||
| size: SpinnerProps['size'] | ||
| variant: SpinnerProps['variant'] | ||
| themeOverride: SpinnerProps['themeOverride'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik we dont need themeOverride here, its handled by useStyle?
| <Spinner renderTitle="Loading" size="small" margin="0 0 0 medium" delay={2000} /> | ||
| <Spinner renderTitle="Loading" margin="0 0 0 medium" delay={3000} /> | ||
| <Spinner renderTitle="Loading" size="large" margin="0 0 0 medium" delay={4000} /> | ||
| <div style={{ display: 'flex', alignItems: 'center', gap: 'spacing.spaceMd' }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cant use this gap value here
| const spinnerSizes = { | ||
| 'x-small': { | ||
| width: componentTheme.xSmallSize, | ||
| height: componentTheme.xSmallSize | ||
| width: componentTheme.containerSizeXs, | ||
| height: componentTheme.containerSizeXs | ||
| }, | ||
| small: { | ||
| width: componentTheme.smallSize, | ||
| height: componentTheme.smallSize | ||
| width: componentTheme.containerSizeSm, | ||
| height: componentTheme.containerSizeSm | ||
| }, | ||
| medium: { | ||
| width: componentTheme.mediumSize, | ||
| height: componentTheme.mediumSize | ||
| width: componentTheme.containerSizeMd, | ||
| height: componentTheme.containerSizeMd | ||
| }, | ||
| large: { | ||
| width: componentTheme.largeSize, | ||
| height: componentTheme.largeSize | ||
| width: componentTheme.containerSizeLg, | ||
| height: componentTheme.containerSizeLg | ||
| } | ||
| } | ||
|
|
||
| const circleSizes = { | ||
| 'x-small': { | ||
| width: componentTheme.xSmallSize, | ||
| height: componentTheme.xSmallSize | ||
| width: componentTheme.containerSizeXs, | ||
| height: componentTheme.containerSizeXs | ||
| }, | ||
| small: { | ||
| width: componentTheme.smallSize, | ||
| height: componentTheme.smallSize | ||
| width: componentTheme.containerSizeSm, | ||
| height: componentTheme.containerSizeSm | ||
| }, | ||
| medium: { | ||
| width: componentTheme.mediumSize, | ||
| height: componentTheme.mediumSize | ||
| width: componentTheme.containerSizeMd, | ||
| height: componentTheme.containerSizeMd | ||
| }, | ||
| large: { | ||
| width: componentTheme.largeSize, | ||
| height: componentTheme.largeSize | ||
| width: componentTheme.containerSizeLg, | ||
| height: componentTheme.containerSizeLg | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 2 are the same, but you are not using the spinnerSize.. tokens
| delay, | ||
| renderTitle, | ||
| margin, | ||
| // elementRef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can delete this
| margin={this.props.margin} | ||
| data-cid="Spinner" | ||
| > | ||
| <div {...passthroughProps} css={styles?.spinner} ref={ref}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data-cid is missing from here
No description provided.