Skip to content

Commit

Permalink
feat(textfield): add tokens for customizing text field selection
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 568270462
  • Loading branch information
AndrewJakubowicz authored and copybara-github committed Oct 3, 2023
1 parent d6f7220 commit 49416e5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
6 changes: 6 additions & 0 deletions textfield/internal/_shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
resize: inherit;
}

.textarea::selection,
.input::selection {
background-color: var(--_text-selection-background-color);
color: var(--_text-selection-color);
}

@include icon.styles;
@include input.styles;
}
17 changes: 10 additions & 7 deletions tokens/_md-comp-filled-text-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ $supported-tokens: (
'supporting-text-line-height',
'supporting-text-size',
'supporting-text-weight',
'text-selection-background-color',
'text-selection-color',
'trailing-icon-color',
'trailing-icon-size',
// go/keep-sorted end
Expand Down Expand Up @@ -123,14 +125,15 @@ $_default: (
$tokens: values.validate(
md-comp-filled-text-field.values($deps, $exclude-hardcoded-values),
$supported-tokens: $supported-tokens,
$unsupported-tokens: $unsupported-tokens
);

$tokens: map.merge(
$tokens,
(
$unsupported-tokens: $unsupported-tokens,
$new-tokens: (
// TODO(b/259455114): remove when focus tokens update to 3px
'focus-active-indicator-height': if($exclude-hardcoded-values, null, 3px)
'focus-active-indicator-height': if($exclude-hardcoded-values, null, 3px),
// TODO(b/231336988): remove when text selection tokens are added
'text-selection-background-color':
if($exclude-hardcoded-values, null, 'Highlight'),
'text-selection-color':
if($exclude-hardcoded-values, null, 'HighlightText')
)
);

Expand Down
17 changes: 10 additions & 7 deletions tokens/_md-comp-outlined-text-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ $supported-tokens: (
'supporting-text-line-height',
'supporting-text-size',
'supporting-text-weight',
'text-selection-background-color',
'text-selection-color',
'trailing-icon-color',
'trailing-icon-size',
// go/keep-sorted end
Expand All @@ -114,14 +116,15 @@ $_default: (
$tokens: values.validate(
md-comp-outlined-text-field.values($deps, $exclude-hardcoded-values),
$supported-tokens: $supported-tokens,
$unsupported-tokens: $unsupported-tokens
);

$tokens: map.merge(
$tokens,
(
$unsupported-tokens: $unsupported-tokens,
$new-tokens: (
// TODO(b/259455114): remove when focus tokens update to 3px
'focus-outline-width': if($exclude-hardcoded-values, null, 3px)
'focus-outline-width': if($exclude-hardcoded-values, null, 3px),
// TODO(b/231336988): remove when text selection tokens are added
'text-selection-background-color':
if($exclude-hardcoded-values, null, 'Highlight'),
'text-selection-color':
if($exclude-hardcoded-values, null, 'HighlightText')
)
);

Expand Down

0 comments on commit 49416e5

Please sign in to comment.