Skip to content

Commit

Permalink
fix: Bootstrap mixins (#1692)
Browse files Browse the repository at this point in the history
- Fixed semantic color mappings for forms and emphasized text.
Validation error labels are now red instead of white. Link sample added
to the styleguide to show proper colors that were incorrectly white
before
- Added anti-aliasing to button text
- font-weight is now bold for outlined buttons (consistent with
Spectrum)

#1693
  • Loading branch information
bmingles authored Dec 14, 2023
1 parent c8a74a2 commit 3934431
Show file tree
Hide file tree
Showing 121 changed files with 54 additions and 14 deletions.
31 changes: 31 additions & 0 deletions packages/code-studio/src/styleguide/Buttons.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react/jsx-props-no-spreading */
import React, { Component, ReactElement } from 'react';
import { Flex } from '@adobe/react-spectrum';
import { Button, ButtonOld, SocketedButton } from '@deephaven/components';
import { dhTruck } from '@deephaven/icons';
import { sampleSectionIdAndClasses } from './utils';
Expand Down Expand Up @@ -47,6 +48,34 @@ class Buttons extends Component<Record<string, never>, ButtonsState> {
);
}

static renderLinks(): ReactElement {
const levelMap = {
primary: 'accent',
secondary: 'neutral',
success: 'positive',
info: 'info',
warning: 'notice',
danger: 'negative',
};

return (
<div
{...sampleSectionIdAndClasses('links')}
style={{ paddingTop: '1rem' }}
>
<h5>Links</h5>
<Flex gap="1rem">
{Object.entries(levelMap).map(([level, semantic]) => (
// eslint-disable-next-line jsx-a11y/anchor-is-valid
<a key={level} className={`text-${level}`}>
{level} ({semantic})
</a>
))}
</Flex>
</div>
);
}

static renderSocketedButtons(): ReactElement {
return (
<div {...sampleSectionIdAndClasses('buttons-socketed')}>
Expand Down Expand Up @@ -139,6 +168,7 @@ class Buttons extends Component<Record<string, never>, ButtonsState> {
const buttons = ['', 'outline'].map(type => Buttons.renderButtons(type));
const inlineButtons = this.renderInlineButtons();
const socketedButtons = Buttons.renderSocketedButtons();
const links = Buttons.renderLinks();

return (
<div>
Expand All @@ -147,6 +177,7 @@ class Buttons extends Component<Record<string, never>, ButtonsState> {
{buttons}
{inlineButtons}
{socketedButtons}
{links}
</div>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions packages/components/scss/BaseStyleSheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ button:focus {
//Make btns a minumum size
.btn {
min-width: 7rem;
// Matching Spectrum styles
-webkit-font-smoothing: antialiased;
}

span.btn-disabled-wrapper {
Expand Down Expand Up @@ -308,6 +310,7 @@ span.btn-disabled-wrapper {
background: var(--dh-color-action-bg);
border: 1px solid var(--dh-color-action-border);
color: var(--dh-color-action-fg);
font-weight: $font-weight-normal;

&.active {
border-color: var(--dh-color-action-active-border);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
$color: var(--dh-color-#{$semantic-value}-contrast);

color: $color;
font-weight: var(--spectrum-global-font-weight-bold);
@include gradient-bg($background);

border-color: $border;
Expand Down
7 changes: 5 additions & 2 deletions packages/components/scss/bootstrap_override_mixins_forms.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* stylelint-disable scss/comment-no-empty */
// Bootstrap mixin overrides for `bootstrap/scss/mixins/_forms.scss`
@use 'sass:map';

// Form control focus state
//
Expand Down Expand Up @@ -38,9 +39,11 @@
// It's primary purpose is to convert the input color value into a dh css
// variable expression. There are a few additional tweaks annotated with
// `DH Customization:`
@mixin form-validation-state($state, $semantic-value, $icon) {
@mixin form-validation-state($state, $bootstrap-value, $icon) {
$semantic-value: map.get($bootstrap-dh-semantic-map, $bootstrap-value) or '';

// DH Customization: Convert semantic value to css variable
$color: var(--dh-color-visual-#{$semantic-value});
$color: var(--dh-color-#{$semantic-value}-bg);

.#{$state}-feedback {
display: none;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Bootstrap mixin overrides for `bootstrap/scss/mixins/_text-emphasis.scss`
@use 'sass:map';

@mixin text-emphasis-variant(
$parent,
$bootstrap-value,
$ignore-warning: false
) {
$semantic-value: map.get($bootstrap-dh-semantic-map, $bootstrap-value) or '';

@mixin text-emphasis-variant($parent, $semantic-value, $ignore-warning: false) {
#{$parent} {
// if $semantic-value = primary then use accent-700
@if $semantic-value == 'accent' {
color: var(--spectrum-#{$semantic-value}-color-700) !important;
} @else {
color: var(--spectrum-#{$semantic-value}-visual-color) !important;
}
color: var(--dh-color-#{$semantic-value}-bg) !important;
}
@if $emphasized-link-hover-darken-percentage != 0 {
a#{$parent} {
@include hover-focus {
color: var(
--spectrum-#{$semantic-value}-background-color-default
) !important;
color: var(--dh-color-#{$semantic-value}-hover-bg) !important;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/components/scss/bootstrap_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ $btn-transition:
border-color 0.12s ease-in-out,
box-shadow 0.12s ease-in-out; //default 0.15 is too long
$btn-border-width: 2px;
$btn-font-weight: var(--spectrum-global-font-weight-bold);

//Override Inputs
$input-bg: var(--dh-color-input-bg);
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/CustomTimeSelect.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ $cs-option-hover-color: $dropdown-link-hover-color;
border-radius: $border-radius;
border: $input-border-width solid $input-border-color;
min-width: 14rem;
font-weight: $font-weight-normal;

.cs-caret {
@include caret-icon;
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/HierarchicalCheckboxMenu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
border: $input-border-width solid $input-border-color;
background-color: $input-bg;
padding: $custom-select-padding-y $custom-select-padding-x;
font-weight: $font-weight-normal;

.cs-caret {
@include caret-icon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
--dh-color-keyboard-selected-bg: hsla(var(--dh-color-accent-hsl), 0.5);

/* Shadows / Overlays */
--dh-color-dropshadow: hsla(var(--dh-color-visual-gray-hsl), 0.8);
--dh-color-dropshadow: hsla(var(--dh-color-true-black-hsl), 0.8);
--dh-color-overlay-modal-bg: hsla(var(--dh-color-visual-gray-hsl), 0.6);
--dh-color-overlay-hover-bg: hsla(var(--dh-color-visual-gray-hsl), 0.08);

Expand Down
1 change: 1 addition & 0 deletions tests/styleguide.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const sampleSectionIds: string[] = [
'sample-section-buttons-outline',
'sample-section-buttons-inline',
'sample-section-buttons-socketed',
'sample-section-links',
'sample-section-progress',
'sample-section-inputs',
'sample-section-item-list-inputs',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/styleguide.spec.ts-snapshots/buttons-outline-webkit-linux.png
Binary file modified tests/styleguide.spec.ts-snapshots/inputs-chromium-linux.png
Binary file modified tests/styleguide.spec.ts-snapshots/inputs-firefox-linux.png
Binary file modified tests/styleguide.spec.ts-snapshots/inputs-webkit-linux.png
Binary file modified tests/styleguide.spec.ts-snapshots/modals-chromium-linux.png
Binary file modified tests/styleguide.spec.ts-snapshots/modals-firefox-linux.png
Binary file modified tests/styleguide.spec.ts-snapshots/modals-webkit-linux.png
Binary file modified tests/styleguide.spec.ts-snapshots/navigations-chromium-linux.png
Binary file modified tests/styleguide.spec.ts-snapshots/navigations-firefox-linux.png
Binary file modified tests/styleguide.spec.ts-snapshots/navigations-webkit-linux.png
Binary file modified tests/table-operations.spec.ts-snapshots/search-1-webkit-linux.png

0 comments on commit 3934431

Please sign in to comment.