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

[New Theme] Rename to Next #835

Merged
merged 1 commit into from
Jun 20, 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
6 changes: 3 additions & 3 deletions scripts/compile-scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ async function compileScssFiles(
const { name } = path.parse(inputFilename);
const outputFilenames = await compileScssFile(
inputFilename,
path.join(destinationDirectory, `eui_${name.replace('cascadia', 'amsterdam')}.css`),
path.join(destinationDirectory, `eui_${name.replace('cascadia', 'amsterdam')}.json`),
path.join(destinationDirectory, `eui_${name.replace('cascadia', 'amsterdam')}.json.d.ts`),
path.join(destinationDirectory, `eui_${name.replace('next', 'amsterdam')}.css`),
path.join(destinationDirectory, `eui_${name.replace('next', 'amsterdam')}.json`),
path.join(destinationDirectory, `eui_${name.replace('next', 'amsterdam')}.json.d.ts`),
packageName,
true
);
Expand Down
4 changes: 2 additions & 2 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ if (!INIT_CWD?.startsWith?.(PWD)) {
const destItem = path
.join(dest, entry.name)
.replace('oui', 'eui')
.replace('cascadia', 'amsterdam');
.replace('next', 'amsterdam');

if (entry.isDirectory()) copyDirectory(srcItem, destItem);
else fs.copyFileSync(srcItem, destItem);
}
};

copyDirectory('src/themes/oui', 'src/themes/eui');
copyDirectory('src/themes/oui-cascadia', 'src/themes/eui-amsterdam');
copyDirectory('src/themes/oui-next', 'src/themes/eui-amsterdam');
}
/* End of Aliases */
8 changes: 4 additions & 4 deletions src-docs/src/components/codesandbox/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export const CodeSandboxLinkComponent = ({
}) => {
let cssFile;
switch (context.theme) {
case 'cascadia-light':
cssFile = '@opensearch-project/oui/dist/oui_theme_cascadia_light.css';
case 'next-light':
cssFile = '@opensearch-project/oui/dist/oui_theme_next_light.css';
break;
case 'cascadia-dark':
cssFile = '@opensearch-project/oui/dist/oui_theme_cascadia_dark.css';
case 'next-dark':
cssFile = '@opensearch-project/oui/dist/oui_theme_next_dark.css';
break;
case 'dark':
cssFile = '@opensearch-project/oui/dist/oui_theme_dark.css';
Expand Down
8 changes: 4 additions & 4 deletions src-docs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ import { registerTheme, ExampleContext } from './services';
import Routes from './routes';
import themeLight from './theme_light.scss';
import themeDark from './theme_dark.scss';
import themeCascadiaLight from './theme_cascadia_light.scss';
import themeCascadiaDark from './theme_cascadia_dark.scss';
import themeNextLight from './theme_next_light.scss';
import themeNextDark from './theme_next_dark.scss';
import { ThemeProvider } from './components/with_theme/theme_context';
import ScrollToHash from './components/scroll_to_hash';
import { LinkWrapper } from './views/link_wrapper';

registerTheme('light', [themeLight]);
registerTheme('dark', [themeDark]);
registerTheme('cascadia-light', [themeCascadiaLight]);
registerTheme('cascadia-dark', [themeCascadiaDark]);
registerTheme('next-light', [themeNextLight]);
registerTheme('next-dark', [themeNextDark]);

// Set up app

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*/

// sass-lint:disable no-url-domains, no-url-protocols
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be replaced with Source Sans & Source Code fonts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good question - @AMoo-Miki I understand we're not packaging the new fonts with OUI, but do we want to do the same thing where we hot link for the purpose of the doc site?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! i knew i forgot something. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To note: here, this is to enable the fonts on the docsite, not to package the fonts with OUI. OUI doesn't package any fonts out of the box, that is up to the implementor

@import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&family=Source+Sans+3:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap');

@import '../../src/theme_cascadia_dark';
@import '../../src/theme_next_dark';
@import './components/guide_components';
@import './services/playground/index';
@import './views/suggest/global_filter_group';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*/

// sass-lint:disable no-url-domains, no-url-protocols
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment

@import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&family=Source+Sans+3:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap');

@import '../../src/theme_cascadia_light';
@import '../../src/theme_next_light';
@import './components/guide_components';
@import './services/playground/index';
@import './views/suggest/global_filter_group';
Expand Down
12 changes: 6 additions & 6 deletions src-docs/src/views/guidelines/_get_sass_vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

import lightColors from '!!sass-vars-to-js-loader!../../../../src/global_styling/variables/_colors.scss';
import darkColors from '!!sass-vars-to-js-loader!../../../../src/themes/oui/oui_colors_dark.scss';
import lightCascadiaColors from '!!sass-vars-to-js-loader!../../../../src/themes/oui-cascadia/oui_cascadia_colors_light.scss';
import darkCascadiaColors from '!!sass-vars-to-js-loader!../../../../src/themes/oui-cascadia/oui_cascadia_colors_dark.scss';
import lightNextColors from '!!sass-vars-to-js-loader!../../../../src/themes/oui-next/oui_next_colors_light.scss';
import darkNextColors from '!!sass-vars-to-js-loader!../../../../src/themes/oui-next/oui_next_colors_dark.scss';

export const getSassVars = (theme) => {
let palette;
switch (theme) {
case 'cascadia-dark':
palette = { ...darkColors, ...darkCascadiaColors };
case 'next-dark':
palette = { ...darkColors, ...darkNextColors };
break;
case 'cascadia-light':
palette = { ...lightColors, ...lightCascadiaColors };
case 'next-light':
palette = { ...lightColors, ...lightNextColors };
break;
case 'dark':
palette = darkColors;
Expand Down
6 changes: 2 additions & 4 deletions src-docs/src/views/panel/panel_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,8 @@ export const PanelExample = {
title="Certain allowed combinations of shadow, border, and color depend on the current theme.">
<p>
For instance, only plain or transparent panels can have a border
and/or shadow. The Cascadia theme doesn&apos;t allow combining the{' '}
<OuiCode>hasBorder</OuiCode> option with{' '}
<OuiCode>hasShadow</OuiCode>. The default theme only allows
removing the border if both <OuiCode>hasShadow</OuiCode> and{' '}
and/or shadow. The default theme only allows removing the border
if both <OuiCode>hasShadow</OuiCode> and{' '}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we renaming cascadia theme to next or is it a different theme altogether (default theme)?

I see difference in the comment here. Is it intended?

The Cascadia theme doesn&apos;t allow combining the{' '}
              <OuiCode>hasBorder</OuiCode> option with{' '}
              <OuiCode>hasShadow</OuiCode>.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cas* was a temporary reference to a temporary and incomplete theme; that was reset to default in #816. The new colors are just named "Next"

<OuiCode>hasBorder</OuiCode> are set to <OuiCode>false</OuiCode>.
</p>
</OuiCallOut>
Expand Down
16 changes: 1 addition & 15 deletions src-docs/src/views/panel/panel_shadow.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@
* GitHub history for details.
*/

import React, { useContext } from 'react';
import React from 'react';

import { OuiPanel, OuiCode, OuiSpacer } from '../../../../src/components';
import { ThemeContext } from '../../components';

export default () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean we have only one theme now (default one)? and do not need theme context anymore to determine the theme?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous beta theme had limitations and ThemeContext was used to apply rules when dealing with those limitations. Next is evolved out of default and as such, has none of those limitations so. there was no need to know the ThemeContext in this file.

const themeContext = useContext(ThemeContext);
Comment on lines -15 to -18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the theme context, and do we still use it elsewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guy is responsible for switching between light and dark themes. I donno how we switch from default to "Next" in the docs but will figure it out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, theme context is responsible for switching between themes in general on docsite, not just light/dark

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matt is right; for OUI, light, dark, next-light, and next-dark are individual themes.

const isCascadiaTheme = themeContext.theme.includes('cascadia');

return (
<div>
<OuiPanel hasShadow={false}>
Expand All @@ -26,16 +22,6 @@ export default () => {

<OuiSpacer />

{/* This example only works for the Cascadia theme. The default theme has `hasBorder={true}` by default. */}
{isCascadiaTheme && (
<>
<OuiPanel hasBorder={true}>
<OuiCode>{'hasBorder={true}'}</OuiCode>
</OuiPanel>
<OuiSpacer />
</>
)}

<OuiPanel hasShadow={false} hasBorder={false}>
<OuiCode>{'hasShadow={false} hasBorder={false}'}</OuiCode>
</OuiPanel>
Expand Down
7 changes: 6 additions & 1 deletion src/components/datagrid/_data_grid_data_row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,13 @@
overflow: hidden;
transition: none; // Have to take out the generic transition so it is instaneous on focus
box-shadow: none !important; // sass-lint:disable-line no-important

/* ToDo: Remove unnecessary logic: the old beta theme has
* evolved and the statement below about the `Next` theme
* is not valid.
*/
// Remove default .ouiButtonIcon--fill border
// This way we don't need to animate the border that is inexistent in Cascadia and unnecessary for a fill button
// This way we don't need to animate the border that is inexistent in Next and unnecessary for a fill button
border: none;

&-isActive {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const borderToClassNameMap: { [border in Border]: string | undefined } = {
export type OuiHeaderSectionItemProps = CommonProps & {
/**
* Side to display a short border on.
* Not supported in Cascadia theme.
*/
border?: Border;
/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/link/_link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ $ouiLinkColors: (

&:focus {
@include ouiFocusBackground($color);
@include ouiFocusRing(null, 0);
@include ouiFocusRing(null);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/page/_restrict_width.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { CSSProperties } from 'react';
export type _OuiPageRestrictWidth = {
/**
* Sets the max-width of the page,
* set to `true` to use the default size of `1000px (1200 for Cascadia)`,
joshuarrrr marked this conversation as resolved.
Show resolved Hide resolved
* set to `true` to use the default size of `1000px`,
* set to `false` to not restrict the width,
* set to a number for a custom width in px,
* set to a string for a custom width in custom measurement.
Expand Down
6 changes: 5 additions & 1 deletion src/components/panel/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,12 @@ export const OuiPanel: FunctionComponent<OuiPanelProps> = ({
borderRadiusToClassNameMap[borderRadius],
`ouiPanel--${color}`,
{
/* ToDo: Remove unnecessary logic: the old beta theme has
* evolved and the statement below about the `Next` theme
* is not valid.
*/
// The `no` classes turn off the option for default theme
// While the `has` classes turn it on for Cascadia
// While the `has` classes turn it on for Next
'ouiPanel--hasShadow': canHaveShadow && hasShadow === true,
'ouiPanel--noShadow': !canHaveShadow || hasShadow === false,
'ouiPanel--hasBorder': canHaveBorder && hasBorder === true,
Expand Down
2 changes: 0 additions & 2 deletions src/components/steps/step_horizontal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ export interface OuiStepHorizontalProps
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'>,
CommonProps {
/**
* **DEPRECATED IN CASCADIA**
* Adds to the line before the indicator for showing current progress
*/
isSelected?: boolean;
/**
* **DEPRECATED IN CASCADIA**
* Adds to the line after the indicator for showing current progress
*/
isComplete?: boolean;
Expand Down
1 change: 0 additions & 1 deletion src/components/steps/step_number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export interface OuiStepNumberProps
status?: OuiStepStatus;
number?: number;
/**
* **DEPRECATED IN CASCADIA**
* Uses a border and removes the step number.
*/
isHollow?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/components/tree_view/tree_view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
text-align-last: left;

&:focus {
@include ouiFocusRing('small', 'inner');
@include ouiFocusRing('small');
}

&:hover,
Expand Down
26 changes: 4 additions & 22 deletions src/global_styling/mixins/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -356,27 +356,9 @@
}
}

@mixin ouiCustomControlFocused($cascadiaSelector: null) {
// Requires a selector to work with the Cascadia outline styles
@if ($cascadiaSelector) {
+ #{$cascadiaSelector} {
outline: $ouiFocusRingSize solid currentColor;
}

// Chrome
&:focus-visible + #{$cascadiaSelector} {
outline-style: auto;
outline-offset: 3px;
}

&:not(:focus-visible) + #{$cascadiaSelector} {
outline: none;
}
} @else {
// Default theme
@include ouiFocusRing('small', 'outer');
border-color: $ouiColorPrimary;
}
@mixin ouiCustomControlFocused {
@include ouiFocusRing('small');
border-color: $ouiColorPrimary;
}

@mixin ouiHiddenSelectableInput {
Expand Down Expand Up @@ -423,6 +405,6 @@
@mixin euiCustomControl($type: null, $size: $ouiSize) { @include ouiCustomControl($type, $size); }
@mixin euiCustomControlSelected($type: null) { @include ouiCustomControlSelected($type); }
@mixin euiCustomControlDisabled($type: null) { @include ouiCustomControlDisabled($type); }
@mixin euiCustomControlFocused($cascadiaSelector: null) { @include ouiCustomControlFocused($cascadiaSelector); }
@mixin euiCustomControlFocused { @include ouiCustomControlFocused; }
@mixin euiHiddenSelectableInput { @include ouiHiddenSelectableInput; }
/* End of Aliases */
4 changes: 2 additions & 2 deletions src/global_styling/mixins/_states.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* GitHub history for details.
*/

@mixin ouiFocusRing($size: 'small', $cascadiaOnlyProp: null) {
@mixin ouiFocusRing($size: 'small') {
@if $size == 'large' {
// It's always OK to use the focus animation. This will take precedence over times we turn it off individually like OuiButtonEmpty
// sass-lint:disable-block no-important
Expand Down Expand Up @@ -62,7 +62,7 @@


/* OUI -> EUI Aliases */
@mixin euiFocusRing($size: 'small', $cascadiaOnlyProp: null) { @include ouiFocusRing($size, $cascadiaOnlyProp); }
@mixin euiFocusRing($size: 'small') { @include ouiFocusRing($size); }
@mixin euiFocusBackground($color: $ouiColorPrimary) { @include ouiFocusBackground($color); }
@mixin euiHoverState { @include ouiHoverState; }
@mixin euiFocusState($color: $ouiColorPrimary) { @include ouiFocusState($color); }
Expand Down
4 changes: 2 additions & 2 deletions src/theme_cascadia_dark.scss → src/theme_next_dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
*/

// These are variable overwrites used only for this theme.
@import 'themes/oui-cascadia/oui_cascadia_colors_dark';
@import 'themes/oui-next/oui_next_colors_dark';

// Global styling
@import 'themes/oui-cascadia/global_styling/index';
@import 'themes/oui-next/global_styling/index';

// Components
@import 'components/index';
Expand Down
4 changes: 2 additions & 2 deletions src/theme_cascadia_light.scss → src/theme_next_light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
*/

// This is the default theme.
@import 'themes/oui-cascadia/oui_cascadia_colors_light';
@import 'themes/oui-next/oui_next_colors_light';

// Global styling
@import 'themes/oui-cascadia/global_styling/index';
@import 'themes/oui-next/global_styling/index';

// Components
@import 'components/index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,27 +356,9 @@
}
}

@mixin ouiCustomControlFocused($cascadiaSelector: null) {
// Requires a selector to work with the Cascadia outline styles
@if ($cascadiaSelector) {
+ #{$cascadiaSelector} {
outline: $ouiFocusRingSize solid currentColor;
}

// Chrome
&:focus-visible + #{$cascadiaSelector} {
outline-style: auto;
outline-offset: 3px;
}

&:not(:focus-visible) + #{$cascadiaSelector} {
outline: none;
}
} @else {
// Default theme
@include ouiFocusRing('small', 'outer');
border-color: $ouiColorPrimary;
}
@mixin ouiCustomControlFocused {
@include ouiFocusRing('small');
border-color: $ouiColorPrimary;
}

@mixin ouiHiddenSelectableInput {
Expand Down Expand Up @@ -423,6 +405,6 @@
@mixin euiCustomControl($type: null, $size: $ouiSize) { @include ouiCustomControl($type, $size); }
@mixin euiCustomControlSelected($type: null) { @include ouiCustomControlSelected($type); }
@mixin euiCustomControlDisabled($type: null) { @include ouiCustomControlDisabled($type); }
@mixin euiCustomControlFocused($cascadiaSelector: null) { @include ouiCustomControlFocused($cascadiaSelector); }
@mixin euiCustomControlFocused { @include ouiCustomControlFocused; }
@mixin euiHiddenSelectableInput { @include ouiHiddenSelectableInput; }
/* End of Aliases */
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* GitHub history for details.
*/

@mixin ouiFocusRing($size: 'small', $cascadiaOnlyProp: null) {
@mixin ouiFocusRing($size: 'small') {
@if $size == 'large' {
// It's always OK to use the focus animation. This will take precedence over times we turn it off individually like OuiButtonEmpty
// sass-lint:disable-block no-important
Expand Down Expand Up @@ -62,7 +62,7 @@


/* OUI -> EUI Aliases */
@mixin euiFocusRing($size: 'small', $cascadiaOnlyProp: null) { @include ouiFocusRing($size, $cascadiaOnlyProp); }
@mixin euiFocusRing($size: 'small') { @include ouiFocusRing($size); }
@mixin euiFocusBackground($color: $ouiColorPrimary) { @include ouiFocusBackground($color); }
@mixin euiHoverState { @include ouiHoverState; }
@mixin euiFocusState($color: $ouiColorPrimary) { @include ouiFocusState($color); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* GitHub history for details.
*/

// Helper file for supplying OUI Cascadia globals (invisibles only)
// Helper file for supplying OUI Next globals (invisibles only)
// Must be imported AFTER a colors modifier file

// Functions need to be first, since we use them in our variables and mixin definitions
Expand Down
Loading
Loading