-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Select): Convert
Select
component to CSS Modules behind featur…
…e flag (#5194) * initial commit * changeset and lint * fix css module comments * fix Select import to please the FormControl component's type comparision * fix slot comparison in form control
- Loading branch information
1 parent
8138dee
commit 719def7
Showing
9 changed files
with
235 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/react': minor | ||
--- | ||
|
||
Migrate `Select` component to css modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react' | ||
import type {Meta} from '@storybook/react' | ||
import {FormControl, Box} from '..' | ||
import Select from './Select' | ||
|
||
export default { | ||
title: 'Components/Select/Dev', | ||
component: Select, | ||
} as Meta | ||
|
||
export const Default = () => ( | ||
<Box as="form"> | ||
<FormControl> | ||
<FormControl.Label>Default label</FormControl.Label> | ||
<Select sx={{color: 'danger.fg'}}> | ||
<Select.Option value="one">Choice one</Select.Option> | ||
<Select.Option value="two">Choice two</Select.Option> | ||
<Select.Option value="three">Choice three</Select.Option> | ||
<Select.Option value="four">Choice four</Select.Option> | ||
<Select.Option value="five">Choice five</Select.Option> | ||
<Select.Option value="six">Choice six</Select.Option> | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
.Select { | ||
width: 100%; | ||
/* stylelint-disable-next-line primer/spacing */ | ||
margin-top: 1px; | ||
/* stylelint-disable-next-line primer/spacing */ | ||
margin-bottom: 1px; | ||
/* stylelint-disable-next-line primer/spacing */ | ||
margin-left: 1px; | ||
font-size: inherit; | ||
color: currentColor; | ||
|
||
/* Firefox hacks: | ||
* 1. Makes Firefox's native dropdown menu's background match the theme. | ||
* background-color should be 'transparent', but Firefox uses the background-color on | ||
* <select> to determine the background color used for the dropdown menu. | ||
* 2. Adds 1px margins to the <select> so the background color doesn't hide the focus outline created with an inset box-shadow. | ||
*/ | ||
background-color: inherit; | ||
border: 0; | ||
border-radius: inherit; | ||
outline: none; | ||
appearance: none; | ||
|
||
/* 2. Prevents visible overlap of partially transparent background colors. | ||
* 'colors.input.disabledBg' happens to be partially transparent in light mode, so we use a | ||
* transparent background-color on a disabled <select>. | ||
*/ | ||
&:disabled { | ||
background-color: transparent; | ||
} | ||
|
||
/* 3. Maintain dark bg color in Firefox on Windows high-contrast mode | ||
* Firefox makes the <select>'s background color white when setting 'background-color: transparent;' | ||
*/ | ||
@media screen and (forced-colors: active) { | ||
&:disabled { | ||
background-color: -moz-combobox; | ||
} | ||
} | ||
} | ||
|
||
.TextInputWrapper { | ||
position: relative; | ||
overflow: hidden; | ||
|
||
@media screen and (forced-colors: active) { | ||
svg { | ||
fill: 'FieldText'; | ||
} | ||
} | ||
} | ||
|
||
.disabled { | ||
@media screen and (forced-colors: active) { | ||
svg { | ||
fill: 'GrayText'; | ||
} | ||
} | ||
} | ||
|
||
.ArrowIndicator { | ||
position: absolute; | ||
top: 50%; | ||
right: var(--base-size-4); | ||
pointer-events: none; | ||
transform: translateY(-50%); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters