Skip to content

Commit

Permalink
Additional updates to v9 theme (#1417) (#1418)
Browse files Browse the repository at this point in the history
- Additional borderRadius sizes on Panels
- Configuration of borderRadius on Cards
- Make Side Nav variables themeable
- Make Links use font-weight `$ouiFontWeightSemiBold`
- Enable themes to define background colors for Buttons

Signed-off-by: Viraj Sanghvi <virajs@amazon.com>
(cherry picked from commit 18ed6db)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 3284bfe commit dbaa9c8
Show file tree
Hide file tree
Showing 28 changed files with 205 additions and 62 deletions.
24 changes: 12 additions & 12 deletions i18ntokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,40 +234,40 @@
"filepath": "src/components/bottom_bar/bottom_bar.tsx"
},
{
"token": "ouiBreadcrumbsSimplified.collapsedBadge.ariaLabel",
"token": "ouiBreadcrumbs.collapsedBadge.ariaLabel",
"defString": "Show collapsed breadcrumbs",
"highlighting": "string",
"loc": {
"start": {
"line": 79,
"line": 157,
"column": 6,
"index": 2234
"index": 4951
},
"end": {
"line": 81,
"line": 159,
"column": 45,
"index": 2354
"index": 5061
}
},
"filepath": "src/components/breadcrumbs/breadcrumbs_simplified.tsx"
"filepath": "src/components/breadcrumbs/breadcrumbs.tsx"
},
{
"token": "ouiBreadcrumbs.collapsedBadge.ariaLabel",
"token": "ouiSimplifiedBreadcrumbs.collapsedBadge.ariaLabel",
"defString": "Show collapsed breadcrumbs",
"highlighting": "string",
"loc": {
"start": {
"line": 147,
"line": 128,
"column": 6,
"index": 4396
"index": 4196
},
"end": {
"line": 149,
"line": 130,
"column": 45,
"index": 4506
"index": 4316
}
},
"filepath": "src/components/breadcrumbs/breadcrumbs.tsx"
"filepath": "src/components/breadcrumbs/simplified_breadcrumbs/simplified_breadcrumbs.tsx"
},
{
"token": "ouiCardSelect.selected",
Expand Down
3 changes: 2 additions & 1 deletion src-docs/src/views/card/card_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ onClick={handleClick}
</p>
<p>
For non-interactive cards, reduce or eliminate the padding as needed
to suit your layout with the prop <OuiCode>paddingSize</OuiCode>.
to suit your layout with the prop <OuiCode>paddingSize</OuiCode>, or
adjust border radius with <OuiCode>borderRadius</OuiCode>.
</p>
</Fragment>
),
Expand Down
14 changes: 14 additions & 0 deletions src-docs/src/views/panel/panel_color.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,19 @@ export default () => (
<OuiPanel color="transparent" hasBorder={false}>
<p>I am a transparent box simply for padding</p>
</OuiPanel>

<OuiSpacer />

{['m', 'l', 'xl'].map((borderRadius) => (
<>
<OuiPanel color="subdued" borderRadius={borderRadius}>
<p>
I am shaded box with{' '}
<code>borderRadius=&quot;{borderRadius}&quot;</code>
</p>
</OuiPanel>
<OuiSpacer />
</>
))}
</div>
);
9 changes: 8 additions & 1 deletion src-docs/src/views/panel/panel_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ const panelColorSnippet = [
`<OuiPanel color="transparent" hasBorder={false}>
<!-- Transparent panel -->
</OuiPanel>`,
...['m', 'l', 'xl'].map(
(borderRadius) =>
`<OuiPanel color="subdued" borderRadius="${borderRadius}">
<!-- Panel with gray background and ${borderRadius} corners -->
</OuiPanel>`
),
];

const panelGrowSnippet = `<OuiPanel grow={false}>
Expand Down Expand Up @@ -198,7 +204,8 @@ export const PanelExample = {
and provide an additional helpful aesthetic to your container in
context. Be mindful to use color sparingly. You can also remove the
rounded corners depending on the placement of your panel with{' '}
<OuiCode language="tsx">{'borderRadius="none"'}</OuiCode>
<OuiCode language="tsx">{'borderRadius="none"'}</OuiCode> or the
border radius size.
</p>
<p>
Passing <OuiCode language="ts">{'color="transparent"'}</OuiCode> can
Expand Down
2 changes: 2 additions & 0 deletions src/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
}

border-radius: $ouiButtonBorderRadius;
background-color: $ouiButtonBackgroundColor;
min-width: $ouiButtonMinWidth;

.ouiButton__content {
Expand Down Expand Up @@ -83,6 +84,7 @@
@if ($name == 'ghost') {
// Ghost is unique and ALWAYS sits against a dark background.
color: $color;
background-color: transparent;
} @else if ($name == 'text') {
// The default color is lighter than the normal text color, make the it the text color
color: $ouiTextColor;
Expand Down
1 change: 1 addition & 0 deletions src/components/button/button_group/_button_group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
@include ouiSlightShadow;
}
border-radius: $ouiButtonBorderRadius + 1px; // Simply for the box-shadow
background-color: $ouiButtonBackgroundColor;
max-width: 100%;
display: flex;
overflow: hidden;
Expand Down
6 changes: 6 additions & 0 deletions src/components/card/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ export type OuiCardProps = Omit<CommonProps, 'aria-label'> &
* Use a border style of card instead of shadow
*/
hasBorder?: OuiPanelProps['hasBorder'];
/**
* Customize card border radius
*/
borderRadius?: OuiPanelProps['borderRadius'];
} & (
| {
// description becomes optional when children is present
Expand Down Expand Up @@ -216,6 +220,7 @@ export const OuiCard: FunctionComponent<OuiCardProps> = ({
selectable,
display,
paddingSize,
borderRadius,
...rest
}) => {
const isHrefValid = !href || validateHref(href);
Expand Down Expand Up @@ -405,6 +410,7 @@ export const OuiCard: FunctionComponent<OuiCardProps> = ({
hasShadow={isDisabled || display ? false : true}
hasBorder={display ? false : undefined}
paddingSize={paddingSize}
borderRadius={borderRadius}
{...rest}>
{optionalCardTop}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@

&.ouiFormControlLayout--compressed {
@include ouiFormControlDefaultShadow($borderOnly: true);
border-radius: calc($ouiBorderRadius / 2);
border-radius: $ouiFormControlCompressedBorderRadius;
overflow: hidden; // Keeps backgrounds inside border radius

// Padding
Expand Down
2 changes: 1 addition & 1 deletion src/components/link/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@mixin ouiLink {
text-align: left;
font-weight: 600;
font-weight: $ouiFontWeightSemiBold;

&:hover {
text-decoration: underline;
Expand Down
12 changes: 12 additions & 0 deletions src/components/panel/__snapshots__/panel.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ exports[`OuiPanel is rendered 1`] = `
/>
`;

exports[`OuiPanel props borderRadius l is rendered 1`] = `
<div
class="ouiPanel ouiPanel--paddingMedium ouiPanel--borderRadiusLarge ouiPanel--plain ouiPanel--hasShadow"
/>
`;

exports[`OuiPanel props borderRadius m is rendered 1`] = `
<div
class="ouiPanel ouiPanel--paddingMedium ouiPanel--borderRadiusMedium ouiPanel--plain ouiPanel--hasShadow"
Expand All @@ -20,6 +26,12 @@ exports[`OuiPanel props borderRadius none is rendered 1`] = `
/>
`;

exports[`OuiPanel props borderRadius xl is rendered 1`] = `
<div
class="ouiPanel ouiPanel--paddingMedium ouiPanel--borderRadiusXLarge ouiPanel--plain ouiPanel--hasShadow"
/>
`;

exports[`OuiPanel props color accent is rendered 1`] = `
<div
class="ouiPanel ouiPanel--paddingMedium ouiPanel--borderRadiusMedium ouiPanel--accent ouiPanel--noShadow ouiPanel--noBorder"
Expand Down
2 changes: 2 additions & 0 deletions src/components/panel/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export const SIZES = keysOf(paddingSizeToClassNameMap);
const borderRadiusToClassNameMap = {
none: 'ouiPanel--borderRadiusNone',
m: 'ouiPanel--borderRadiusMedium',
l: 'ouiPanel--borderRadiusLarge',
xl: 'ouiPanel--borderRadiusXLarge',
};

export const BORDER_RADII = keysOf(borderRadiusToClassNameMap);
Expand Down
1 change: 0 additions & 1 deletion src/components/side_nav/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* GitHub history for details.
*/

@import 'variables';
@import 'mixins';

@import 'side_nav';
Expand Down
12 changes: 12 additions & 0 deletions src/components/split_button/_split_button_control.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ $splitButtonSeparatorColor: shade($ouiColorPrimary, 50%);
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;

&:not(.ouiButton--fill) {
background: transparent;
}

&:hover,
&:active,
&:focus {
Expand All @@ -36,6 +40,10 @@ $splitButtonSeparatorColor: shade($ouiColorPrimary, 50%);
border-width: 0px;
border-radius: 0px;

&:not(.ouiButtonIcon--fill) {
background: transparent;
}

&:hover,
&:active,
&:focus {
Expand All @@ -47,6 +55,10 @@ $splitButtonSeparatorColor: shade($ouiColorPrimary, 50%);
.ouiSplitButtonControl {
border: $ouiBorderWidthThick solid $ouiBorderColor;
border-radius: $ouiButtonBorderRadius;

&:not(.ouiButton) {
background: $ouiButtonBackgroundColor;
}
}

// Create button modifiers based upon the map.
Expand Down
2 changes: 2 additions & 0 deletions src/global_styling/variables/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $ouiButtonColorDisabledText: makeDisabledContrastColor($ouiButtonColorDisabled)
$ouiButtonColorGhostDisabled: lightOrDarkTheme($ouiColorDarkShade, $ouiColorLightShade) !default;

$ouiButtonBorderRadius: $ouiBorderRadius !default;
$ouiButtonBackgroundColor: transparent;

// Modifier naming and colors.
$ouiButtonTypes: (
Expand All @@ -42,5 +43,6 @@ $euiButtonColorDisabled: $ouiButtonColorDisabled;
$euiButtonColorDisabledText: $ouiButtonColorDisabledText;
$euiButtonColorGhostDisabled: $ouiButtonColorGhostDisabled;
$euiButtonBorderRadius: $ouiButtonBorderRadius;
$euiButtonBackgroundColor: $ouiButtonBackgroundColor;
$euiButtonTypes: $ouiButtonTypes;
/* End of Aliases */
1 change: 1 addition & 0 deletions src/global_styling/variables/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
@import 'panel';
@import 'tool_tip';
@import 'collapsible_nav';
@import 'side_nav';
2 changes: 2 additions & 0 deletions src/global_styling/variables/_panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ $ouiPanelPaddingModifiers: (
$ouiPanelBorderRadiusModifiers: (
'borderRadiusNone': 0,
'borderRadiusMedium': $ouiBorderRadius,
'borderRadiusLarge': $ouiBorderRadius * 2,
'borderRadiusXLarge': $ouiBorderRadius * 4,
) !default;

$ouiPanelBackgroundColorModifiers: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* GitHub history for details.
*/

$ouiSideNavEmphasizedBackgroundColor: transparentize($ouiColorLightShade, .7);
$ouiSideNavEmphasizedBackgroundColor: transparentize($ouiColorLightShade, .7) !default;

// Simulates the transparent backround on top of the page background to get an opaque color
// in order to get the right contrast for text
Expand All @@ -20,10 +20,10 @@ $ouiSideNavEmphasizedBackgroundColor: transparentize($ouiColorLightShade, .7);
}

// Ensure all the possible text color have proper contrast when "emphasized"
$ouiSideNavRootTextcolor: ouiSideNavEmphasizedContrast($ouiTitleColor);
$ouiSideNavBranchTextcolor: ouiSideNavEmphasizedContrast($ouiTextSubduedColor);
$ouiSideNavSelectedTextcolor: ouiSideNavEmphasizedContrast($ouiColorPrimary);
$ouiSideNavDisabledTextcolor: ouiSideNavEmphasizedContrast($ouiButtonColorDisabledText, $ouiContrastRatioDisabled);
$ouiSideNavRootTextcolor: ouiSideNavEmphasizedContrast($ouiTitleColor) !default;
$ouiSideNavBranchTextcolor: ouiSideNavEmphasizedContrast($ouiTextSubduedColor) !default;
$ouiSideNavSelectedTextcolor: ouiSideNavEmphasizedContrast($ouiColorPrimary) !default;
$ouiSideNavDisabledTextcolor: ouiSideNavEmphasizedContrast($ouiButtonColorDisabledText, $ouiContrastRatioDisabled) !default;


/* OUI -> EUI Aliases */
Expand Down
2 changes: 2 additions & 0 deletions src/themes/oui-next/global_styling/variables/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $ouiButtonColorDisabledText: makeDisabledContrastColor($ouiButtonColorDisabled)
$ouiButtonColorGhostDisabled: lightOrDarkTheme($ouiColorDarkShade, $ouiColorLightShade) !default;

$ouiButtonBorderRadius: $ouiBorderRadius !default;
$ouiButtonBackgroundColor: transparent;

// Modifier naming and colors.
$ouiButtonTypes: (
Expand All @@ -42,5 +43,6 @@ $euiButtonColorDisabled: $ouiButtonColorDisabled;
$euiButtonColorDisabledText: $ouiButtonColorDisabledText;
$euiButtonColorGhostDisabled: $ouiButtonColorGhostDisabled;
$euiButtonBorderRadius: $ouiButtonBorderRadius;
$euiButtonBackgroundColor: $ouiButtonBackgroundColor;
$euiButtonTypes: $ouiButtonTypes;
/* End of Aliases */
1 change: 1 addition & 0 deletions src/themes/oui-next/global_styling/variables/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
@import 'panel';
@import 'tool_tip';
@import 'collapsible_nav';
@import 'side_nav';
2 changes: 2 additions & 0 deletions src/themes/oui-next/global_styling/variables/_panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ $ouiPanelPaddingModifiers: (
$ouiPanelBorderRadiusModifiers: (
'borderRadiusNone': 0,
'borderRadiusMedium': $ouiBorderRadius,
'borderRadiusLarge': $ouiBorderRadius * 2,
'borderRadiusXLarge': $ouiBorderRadius * 4,
) !default;

$ouiPanelBackgroundColorModifiers: (
Expand Down
36 changes: 36 additions & 0 deletions src/themes/oui-next/global_styling/variables/_side_nav.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*!
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

$ouiSideNavEmphasizedBackgroundColor: transparentize($ouiColorLightShade, .7) !default;

// Simulates the transparent backround on top of the page background to get an opaque color
// in order to get the right contrast for text
@function ouiSideNavEmphasizedContrast($textColor, $ratio: $ouiContrastRatioText) {
$backgroundColorSimulated: mix($ouiPageBackgroundColor, $ouiColorLightShade, 70%);
$color: makeHighContrastColor($textColor, $backgroundColorSimulated, $ratio);
@return $color;
}

// Ensure all the possible text color have proper contrast when "emphasized"
$ouiSideNavRootTextcolor: ouiSideNavEmphasizedContrast($ouiTitleColor) !default;
$ouiSideNavBranchTextcolor: ouiSideNavEmphasizedContrast($ouiTextSubduedColor) !default;
$ouiSideNavSelectedTextcolor: ouiSideNavEmphasizedContrast($ouiColorPrimary) !default;
$ouiSideNavDisabledTextcolor: ouiSideNavEmphasizedContrast($ouiButtonColorDisabledText, $ouiContrastRatioDisabled) !default;


/* OUI -> EUI Aliases */
$euiSideNavEmphasizedBackgroundColor: $ouiSideNavEmphasizedBackgroundColor;
$euiSideNavRootTextcolor: $ouiSideNavRootTextcolor;
$euiSideNavBranchTextcolor: $ouiSideNavBranchTextcolor;
$euiSideNavSelectedTextcolor: $ouiSideNavSelectedTextcolor;
$euiSideNavDisabledTextcolor: $ouiSideNavDisabledTextcolor;
@function euiSideNavEmphasizedContrast($textColor, $ratio: $ouiContrastRatioText) { @return ouiSideNavEmphasizedContrast($textColor, $ratio); }
/* End of Aliases */
6 changes: 4 additions & 2 deletions src/themes/v9/global_styling/variables/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ $ouiButtonHeightSmall: $ouiSizeXL !default;
$ouiButtonHeightXSmall: $ouiSizeL !default;

// sass-lint:disable no-color-literals
$ouiButtonColorDisabled: lightOrDarkTheme($ouiColorMediumShade, $ouiColorLightShade) !default;
$ouiButtonColorDisabled: lightOrDarkTheme(#AFAFAF, $ouiColorLightShade) !default;
// Only increase the contrast of background color to text to 2.0 for disabled
$ouiButtonColorDisabledText: lightOrDarkTheme(#8E8E8E, #585858) !default;
// sass-lint:disable no-color-literals
$ouiButtonColorGhostDisabled: lightOrDarkTheme(#585858, #353535) !default;

$ouiButtonBorderRadius: 0 !default;
$ouiButtonBorderRadius: $ouiBorderRadius !default;
$ouiButtonBackgroundColor: $ouiColorEmptyShade;

// Modifier naming and colors.
$ouiButtonTypes: (
Expand All @@ -44,5 +45,6 @@ $euiButtonColorDisabled: $ouiButtonColorDisabled;
$euiButtonColorDisabledText: $ouiButtonColorDisabledText;
$euiButtonColorGhostDisabled: $ouiButtonColorGhostDisabled;
$euiButtonBorderRadius: $ouiButtonBorderRadius;
$euiButtonBackgroundColor: $ouiButtonBackgroundColor;
$euiButtonTypes: $ouiButtonTypes;
/* End of Aliases */
Loading

0 comments on commit dbaa9c8

Please sign in to comment.