Skip to content
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

[Emotion] Add new focus.transparency and focus.backgroundColor theme tokens #6984

Merged
merged 4 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions src/global_styling/variables/states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@
import { ColorModeSwitch } from '../../services/theme/types';
import { CSSProperties } from 'react';

/**
* NOTE: These were quick conversions of their Sass counterparts.
* The commented out keys have not been established as necessary yet.
*/

export interface _EuiThemeFocusOutline {
/**
* A single CSS property: value
*/
[key: string]: ColorModeSwitch;
}

export interface _EuiThemeFocus {
/**
* Default color of the focus ring, some components may override this property
Expand All @@ -33,15 +21,13 @@ export interface _EuiThemeFocus {
*/
width: CSSProperties['borderWidth'];
/**
* Used to transparentize any color at certain values
*/
// transparency: ColorModeSwitch<number>;
/**
* Default color plus transparency
* Used to transparentize the focus background color
* - Default value: { LIGHT: 0.1, DARK: 0.2 }
*/
// backgroundColor: ColorModeSwitch;
transparency: ColorModeSwitch<number>;
/**
* Using `outline` is new for Amsterdam but is set to `none` in legacy theme
* Default focus background color. Not all components set a background color on focus
* - Default value: `colors.primary` computed with `focus.transparency`
*/
// outline: _EuiThemeFocusOutline;
backgroundColor: ColorModeSwitch;
}
22 changes: 7 additions & 15 deletions src/themes/amsterdam/global_styling/variables/_states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,18 @@
* Side Public License, v 1.
*/

/**
* NOTE: These were quick conversions of their Sass counterparts.
* The commented out keys have not been established as necessary yet.
*/

import { computed } from '../../../../services/theme/utils';
import { transparentize } from '../../../../services/color/manipulation';
import { _EuiThemeFocus } from '../../../../global_styling/variables/states';
import { sizeToPixel } from '../../../../global_styling/functions/size';

export const focus: _EuiThemeFocus = {
// Focus ring
color: 'currentColor',
width: computed(sizeToPixel(0.125)),

// transparency: { LIGHT: 0.9, DARK: 0.7 },
// backgroundColor: computed(({ colors, focus }) =>
// transparentize(colors.primary, focus!.transparency)
// ),

// Outline
// outline: {
// outline: computed(({ focus }) => `${focus!.width} solid ${focus!.color}`),
// },
// Focus background
transparency: { LIGHT: 0.1, DARK: 0.2 },
backgroundColor: computed(({ colors, focus }) =>
transparentize(colors.primary, focus.transparency)
),
};
3 changes: 3 additions & 0 deletions upcoming_changelogs/6984.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**CSS-in-JS conversions**

- Added `focus.transparency` and `focus.backgroundColor` theme tokens
Loading