-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
InputBase: Add isBorderless
prop
#58750
Changes from 1 commit
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 |
---|---|---|
|
@@ -213,7 +213,7 @@ export const Input = styled.input< InputProps >` | |
box-sizing: border-box; | ||
border: none; | ||
box-shadow: none !important; | ||
color: ${ COLORS.gray[ 900 ] }; | ||
color: ${ COLORS.theme.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. Unrelated to borderless, but I'd like to sneak in this small enhancement for better themability if that's ok 🥺 |
||
display: block; | ||
font-family: inherit; | ||
margin: 0; | ||
|
@@ -263,28 +263,31 @@ export const LabelWrapper = styled( FlexItem )` | |
|
||
type BackdropProps = { | ||
disabled?: boolean; | ||
isBorderless?: boolean; | ||
isFocused?: boolean; | ||
}; | ||
|
||
const backdropFocusedStyles = ( { | ||
disabled, | ||
isBorderless, | ||
isFocused, | ||
}: BackdropProps ): SerializedStyles => { | ||
let borderColor = isFocused ? COLORS.ui.borderFocus : COLORS.ui.border; | ||
let borderColor = isBorderless ? 'transparent' : COLORS.ui.border; | ||
|
||
let boxShadow; | ||
let outline; | ||
let outlineOffset; | ||
|
||
if ( isFocused ) { | ||
borderColor = COLORS.ui.borderFocus; | ||
boxShadow = CONFIG.controlBoxShadowFocus; | ||
// Windows High Contrast mode will show this outline, but not the box-shadow. | ||
outline = `2px solid transparent`; | ||
outlineOffset = `-2px`; | ||
} | ||
|
||
if ( disabled ) { | ||
borderColor = COLORS.ui.borderDisabled; | ||
borderColor = isBorderless ? 'transparent' : COLORS.ui.borderDisabled; | ||
} | ||
|
||
return css( { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,6 +176,12 @@ export interface InputBaseProps extends BaseProps, FlexProps { | |
* If this property is added, a label will be generated using label property as the content. | ||
*/ | ||
label?: ReactNode; | ||
/** | ||
* Whether to hide the border when not focused. | ||
* | ||
* @default false | ||
*/ | ||
isBorderless?: boolean; | ||
Comment on lines
+179
to
+184
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. This prop shouldn't be exposed in the APIs of any public component. |
||
} | ||
|
||
export interface InputControlProps | ||
|
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.
Technically, we can already just use this
.components-input-control__backdrop
selector to override border styles from any consumer. Still, I think it's better to control this centrally because it's intertwined with the border styles in the focused and disabled states, as you can see in theinput-control-styles.tsx
file.