Skip to content

chore: Refactor SearchForm to use our styling API #3303

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

Conversation

mannycarrera4
Copy link
Contributor

@mannycarrera4 mannycarrera4 commented May 15, 2025

Summary

Fixes: #3272

Release Category

Components

Release Note

  • SearchThemeAttributes type has been updated. Both boxShadow and boxShadowFocus now only accept a string instead of string | string[].
  • SearchTheme enum type has been updated to have string values light, dark and transparent. This should not affect the way you use the type unless you're passing a number of 0, 1 or 2 to the searchTheme prop.

Checklist

For the Reviewer

  • PR title is short and descriptive
  • PR summary describes the change (Fixes/Resolves linked correctly)
  • PR Release Notes describes additional information useful to call out in a release message or removed if not applicable
  • Breaking Changes provides useful information to upgrade to this code or removed if not applicable

Where Should the Reviewer Start?

Areas for Feedback? (optional)

  • Code
  • Documentation
  • Testing
  • Codemods

Testing Manually

Screenshots or GIFs (if applicable)

Thank You Gif (optional)

Copy link

cypress bot commented May 15, 2025

Workday/canvas-kit    Run #8904

Run Properties:  status check passed Passed #8904  •  git commit fe4ca23c1b ℹ️: Merge 02eda69f193cf4df6ca9e917d8e17306e56d29d5 into 901039164ec5ea36c5aa4286cff2...
Project Workday/canvas-kit
Branch Review mc-search-from-refactor
Run status status check passed Passed #8904
Run duration 02m 55s
Commit git commit fe4ca23c1b ℹ️: Merge 02eda69f193cf4df6ca9e917d8e17306e56d29d5 into 901039164ec5ea36c5aa4286cff2...
Committer Manuel Carrera
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 2
Tests that did not run due to a developer annotating a test with .skip  Pending 21
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 936
View all changes introduced in this branch ↗︎
UI Coverage  21.19%
  Untested elements 1538  
  Tested elements 411  
Accessibility  99.29%
  Failed rules  6 critical   5 serious   0 moderate   2 minor
  Failed elements 97  

@mannycarrera4 mannycarrera4 marked this pull request as ready for review May 19, 2025 18:39
@@ -15,8 +15,8 @@ export interface SearchThemeAttributes {
colorFocus?: string;
placeholderColor?: string;
placeholderColorFocus?: string;
boxShadow?: string | string[];
boxShadowFocus?: string | string[];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This technically a breaking change, but in most cases you would just pass a string so I think it's ok. This wouldn't work with the stencil if it accepted an array i think.

Copy link
Member

Choose a reason for hiding this comment

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

This is okay. The original code was matching the Emotion types where an array of strings meant the boxShadow property would be listed multiple times. This is done for browser fallbacks when a property isn't understood by the parser. It is extremely rare to do this now with our drop in IE11 support.

boxShadow: ['first', 'second']

// CSS
box-shadow: first;
box-shadow: second;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohhh

expect(chroma(style.color || '').hex()).toBe(searchThemes[theme].color);
expect(style.boxShadow).toBe(searchThemes[theme].boxShadow);
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These test where visual, so i deleted them an instead added visual regression tests.

@@ -118,173 +117,318 @@ function getInputColors(theme: SearchThemeAttributes, isFocused?: boolean) {
};
}

const formCollapsedBackground = colors.frenchVanilla100;
const formCollapsedBackground = '#fff';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used for chroma and I can't have a css variable. I'm not actually styling the button, it's just used in getIconButtonType to determine if it's inverse or not.

grow: {
true: {
maxWidth: '100%',
[`[data-part="search-form-field"], [data-part="search-form-input"]`]: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to do this because parts aren't part of the compound modifiers.

Copy link
Member

Choose a reason for hiding this comment

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

Oops. We should add that.

@mannycarrera4 mannycarrera4 removed the ready for review Code is ready for review label May 22, 2025
@mannycarrera4 mannycarrera4 added the ready for review Code is ready for review label May 28, 2025
Comment on lines 111 to 113
console.log('theme.backgroundFocus', theme.backgroundFocus);
console.log(isFocused);
console.log('theme background', theme.background);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we removing these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol yep

Comment on lines +132 to +135
background: colors.cinnamon600,
backgroundFocus: colors.frenchVanilla100,
placeholderColor: colors.frenchVanilla100,
placeholderColorFocus: colors.blackPepper400,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should colors used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah no, I'll add some random hex stuff

Copy link
Contributor

@RayRedGoose RayRedGoose left a comment

Choose a reason for hiding this comment

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

LGTM 🌳

@RayRedGoose RayRedGoose added the approved Code has been reviewed and approved (ship it) label Jun 4, 2025
@mannycarrera4 mannycarrera4 removed the ready for review Code is ready for review label Jun 5, 2025
@alanbsmith alanbsmith merged commit 3c15a81 into Workday:prerelease/major Jun 5, 2025
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Code has been reviewed and approved (ship it) automerge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants