-
Notifications
You must be signed in to change notification settings - Fork 538
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
feat(Select): Convert Select
component to CSS Modules behind feature flag
#5194
Changes from all commits
3caf0ae
f103d90
5b65d42
60fd753
e9b9710
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 @@ | ||
--- | ||
'@primer/react': minor | ||
--- | ||
|
||
Migrate `Select` component to css modules |
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> | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React from 'react' | ||
import {Select} from '../../src' | ||
import Select from '.' | ||
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. Get |
||
import FormControl from '../FormControl' | ||
import figma from '@figma/code-connect' | ||
|
||
|
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%); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,8 +137,9 @@ export {default as RadioGroup} from './RadioGroup' | |
export type {RelativeTimeProps} from './RelativeTime' | ||
export {default as RelativeTime} from './RelativeTime' | ||
export {SegmentedControl} from './SegmentedControl' | ||
export {default as Select} from './Select' | ||
export type {SelectProps} from './Select' | ||
// Curently there is a duplicate Select component at the root of the dir, so need to be explicit about exporting from the src/Select dir | ||
export {default as Select} from './Select/Select' | ||
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. @joshblack Should I explore deleting the 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. That would be very much so appreciated if you have the time! 🙏 |
||
export type {SelectProps} from './Select/Select' | ||
export {SelectPanel} from './SelectPanel' | ||
export type {SelectPanelProps} from './SelectPanel' | ||
export {default as SideNav} from './SideNav' | ||
|
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.
Use the newest
Select
component