Unverified Commit 8331b8c0 authored by rauno's avatar rauno Committed by GitHub

[dev-overlay] Customize `<select>` styling for consistency (#76973)

This PR applies `all: unset` to the `<select>` we use in Preferences for
the Dev Overlay and adds a custom icon because we lose the chevron as
soon as we apply this.

Why?

So the styling for the control would look more consistent, for example
this is what it looks like in Safari now:

![CleanShot 2025-03-11 at 12 36
12@2x](https://github.com/user-attachments/assets/a6da93ce-2b89-4420-8165-c58d4ec8ba29)

And after the changes:

![CleanShot 2025-03-11 at 12 36
24@2x](https://github.com/user-attachments/assets/4f0f4c31-cc0f-436b-9575-e4434c783b4e)

---
Closes NDX-928
parent 2bad482f
...@@ -71,22 +71,17 @@ export function UserPreferences({ ...@@ -71,22 +71,17 @@ export function UserPreferences({
Select your theme preference. Select your theme preference.
</p> </p>
</div> </div>
<div className="preference-control-select"> <Select
<div className="preference-icon"> id="theme"
<ThemeIcon theme={theme as 'dark' | 'light' | 'system'} /> name="theme"
</div> prefix={<ThemeIcon theme={theme as 'dark' | 'light' | 'system'} />}
<select value={theme}
id="theme" onChange={handleThemeChange}
name="theme" >
className="select-button" <option value="system">System</option>
value={theme} <option value="light">Light</option>
onChange={handleThemeChange} <option value="dark">Dark</option>
> </Select>
<option value="system">System</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</div>
</div> </div>
<div className="preference-section"> <div className="preference-section">
...@@ -96,20 +91,17 @@ export function UserPreferences({ ...@@ -96,20 +91,17 @@ export function UserPreferences({
Adjust the placement of your dev tools. Adjust the placement of your dev tools.
</p> </p>
</div> </div>
<div className="preference-control-select"> <Select
<select id="position"
id="position" name="position"
name="position" value={position}
className="select-button" onChange={handlePositionChange}
value={position} >
onChange={handlePositionChange} <option value="bottom-left">Bottom Left</option>
> <option value="bottom-right">Bottom Right</option>
<option value="bottom-left">Bottom Left</option> <option value="top-left">Top Left</option>
<option value="bottom-right">Bottom Right</option> <option value="top-right">Top Right</option>
<option value="top-left">Top Left</option> </Select>
<option value="top-right">Top Right</option>
</select>
</div>
</div> </div>
<div className="preference-section"> <div className="preference-section">
...@@ -129,9 +121,7 @@ export function UserPreferences({ ...@@ -129,9 +121,7 @@ export function UserPreferences({
className="action-button" className="action-button"
onClick={hide} onClick={hide}
> >
<div className="preference-icon"> <EyeIcon />
<EyeIcon />
</div>
<span>Hide</span> <span>Hide</span>
</button> </button>
</div> </div>
...@@ -153,6 +143,22 @@ export function UserPreferences({ ...@@ -153,6 +143,22 @@ export function UserPreferences({
) )
} }
function Select({
children,
prefix,
...props
}: {
prefix?: React.ReactNode
} & Omit<React.HTMLProps<HTMLSelectElement>, 'prefix'>) {
return (
<div className="select-button">
{prefix}
<select {...props}>{children}</select>
<ChevronDownIcon />
</div>
)
}
function ThemeIcon({ theme }: { theme: 'dark' | 'light' | 'system' }) { function ThemeIcon({ theme }: { theme: 'dark' | 'light' | 'system' }) {
switch (theme) { switch (theme) {
case 'system': case 'system':
...@@ -213,13 +219,6 @@ export const DEV_TOOLS_INFO_USER_PREFERENCES_STYLES = css` ...@@ -213,13 +219,6 @@ export const DEV_TOOLS_INFO_USER_PREFERENCES_STYLES = css`
margin: 0; margin: 0;
} }
.preference-icon {
display: flex;
align-items: center;
width: 16px;
height: 16px;
}
.select-button, .select-button,
.action-button { .action-button {
display: flex; display: flex;
...@@ -238,31 +237,14 @@ export const DEV_TOOLS_INFO_USER_PREFERENCES_STYLES = css` ...@@ -238,31 +237,14 @@ export const DEV_TOOLS_INFO_USER_PREFERENCES_STYLES = css`
} }
} }
.preference-control-select { .select-button {
padding: 6px 8px;
display: flex;
align-items: center;
gap: 8px;
border-radius: var(--rounded-lg);
border: 1px solid var(--color-gray-400);
&:hover {
background: var(--color-gray-100);
}
&:focus-within { &:focus-within {
outline: var(--focus-ring); outline: var(--focus-ring);
} }
}
.preference-control-select select { select {
font-size: var(--size-14); all: unset;
font-weight: 400; }
border: none;
padding: 0 6px 0 0;
border-radius: 0;
outline: none;
background: none;
} }
:global(.icon) { :global(.icon) {
...@@ -271,3 +253,16 @@ export const DEV_TOOLS_INFO_USER_PREFERENCES_STYLES = css` ...@@ -271,3 +253,16 @@ export const DEV_TOOLS_INFO_USER_PREFERENCES_STYLES = css`
color: #666; color: #666;
} }
` `
function ChevronDownIcon() {
return (
<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M14.0607 5.49999L13.5303 6.03032L8.7071 10.8535C8.31658 11.2441 7.68341 11.2441 7.29289 10.8535L2.46966 6.03032L1.93933 5.49999L2.99999 4.43933L3.53032 4.96966L7.99999 9.43933L12.4697 4.96966L13 4.43933L14.0607 5.49999Z"
fill="currentColor"
/>
</svg>
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment