-
Notifications
You must be signed in to change notification settings - Fork 10
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
[WB-1814.2] Refactor TextField and TextArea to use semantic colors #2440
Changes from 3 commits
0560b01
e29bb49
6087b43
f5683ce
b4b0762
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/wonder-blocks-form": patch | ||
--- | ||
|
||
Migrate color instances to use semanticColor internally on TextField and TextArea |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/wonder-blocks-tokens": minor | ||
--- | ||
|
||
Add `border.focus` semantic color token to use for the focus outline |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,12 @@ import { | |
addStyle, | ||
View, | ||
} from "@khanacademy/wonder-blocks-core"; | ||
import {border, color, font, spacing} from "@khanacademy/wonder-blocks-tokens"; | ||
import { | ||
border, | ||
font, | ||
semanticColor, | ||
spacing, | ||
} from "@khanacademy/wonder-blocks-tokens"; | ||
import {styles as typographyStyles} from "@khanacademy/wonder-blocks-typography"; | ||
import {useId} from "react"; | ||
import {useFieldValidation} from "../hooks/use-field-validation"; | ||
|
@@ -312,45 +317,45 @@ const styles = StyleSheet.create({ | |
}px`, | ||
}, | ||
default: { | ||
background: color.white, | ||
border: `1px solid ${color.offBlack50}`, | ||
color: color.offBlack, | ||
background: semanticColor.surface.primary, | ||
border: `${border.width.hairline}px solid ${semanticColor.border.strong}`, | ||
color: semanticColor.text.primary, | ||
"::placeholder": { | ||
color: color.offBlack64, | ||
color: semanticColor.text.secondary, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here around if we want to have a separate token for placeholder text color! (comment from other PR: #2438 (comment)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed with Design and they are good with this approach. |
||
}, | ||
}, | ||
defaultFocus: { | ||
":focus-visible": { | ||
borderColor: color.blue, | ||
outline: `1px solid ${color.blue}`, | ||
borderColor: semanticColor.border.focus, | ||
outline: `${border.width.hairline}px solid ${semanticColor.border.focus}`, | ||
// Negative outline offset so it focus outline is not cropped off if | ||
// an ancestor element has overflow: hidden | ||
outlineOffset: "-2px", | ||
outlineOffset: -2, | ||
}, | ||
}, | ||
disabled: { | ||
background: color.offWhite, | ||
border: `1px solid ${color.offBlack16}`, | ||
color: color.offBlack64, | ||
background: semanticColor.action.disabled.secondary, | ||
border: `${border.width.hairline}px solid ${semanticColor.border.primary}`, | ||
color: semanticColor.text.secondary, | ||
"::placeholder": { | ||
color: color.offBlack64, | ||
color: semanticColor.text.secondary, | ||
}, | ||
cursor: "not-allowed", | ||
":focus-visible": { | ||
outline: `2px solid ${color.offBlack32}`, | ||
outlineOffset: "-3px", | ||
outline: `${border.width.thin}px solid ${semanticColor.action.disabled.default}`, | ||
outlineOffset: -3, | ||
}, | ||
}, | ||
error: { | ||
background: color.fadedRed8, | ||
border: `1px solid ${color.red}`, | ||
color: color.offBlack, | ||
background: semanticColor.status.critical.background, | ||
border: `${border.width.hairline}px solid ${semanticColor.status.critical.foreground}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned in other PRs, the goal is to keep |
||
color: semanticColor.text.primary, | ||
"::placeholder": { | ||
color: color.offBlack64, | ||
color: semanticColor.text.secondary, | ||
}, | ||
":focus-visible": { | ||
outlineColor: color.red, | ||
borderColor: color.red, | ||
outlineColor: semanticColor.status.critical.foreground, | ||
borderColor: semanticColor.status.critical.foreground, | ||
}, | ||
}, | ||
}); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comments from TextArea for TextField since they have similar styles! |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ const border = { | |
primary: color.fadedOffBlack16, | ||
subtle: color.fadedOffBlack8, | ||
strong: color.fadedOffBlack50, | ||
focus: color.blue, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
inverse: color.white, | ||
}; | ||
|
||
|
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.
So clean and straightforward 🤩