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

fix(@clayui/css): Mixins clay-select-variant update to use `clay-cs… #4047

Merged
merged 2 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix(@clayui/css): Mixins clay-select-variant update to use `clay-cs…
…s` pattern, also deprecated keys should win over new keys

fix(@clayui/css): Update Sass maps that use `clay-select-variant` to use new keys: `$date-picker-nav-select` and `$input-select`
  • Loading branch information
pat270 committed May 12, 2021
commit 65ad45ed4fd58a1de82c2a11c5271c8c9cd43d6a
20 changes: 13 additions & 7 deletions packages/clay-css/src/scss/atlas/variables/_date-picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $date-picker-nav-btn: map-deep-merge(
$date-picker-nav-select: () !default;
$date-picker-nav-select: map-deep-merge(
(
bg: transparent,
background-color: transparent,
border-color: transparent,
color: $secondary,
font-size: $font-size-sm,
Expand All @@ -35,12 +35,18 @@ $date-picker-nav-select: map-deep-merge(
padding-bottom: 0,
padding-left: 0.5rem,
padding-top: 0,
hover-bg: $gray-200,
hover-color: $gray-900,
focus-bg: $gray-200,
focus-color: $gray-900,
disabled-bg: transparent,
disabled-color: $input-disabled-color,
hover: (
background-color: $gray-200,
color: $gray-900,
),
focus: (
background-color: $gray-200,
color: $gray-900,
),
disabled: (
background-color: transparent,
color: $input-disabled-color,
),
),
$date-picker-nav-select
);
Expand Down
115 changes: 88 additions & 27 deletions packages/clay-css/src/scss/mixins/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@

$base: setter($map, ());
$base: map-merge(
$map,
$base,
(
background-color:
setter(map-get($map, bg), map-get($map, background-color)),
Expand Down Expand Up @@ -568,48 +568,109 @@
)
);

$hover: setter(map-get($map, hover), ());
$hover: map-deep-merge(
$hover,
(
background-color: map-get($map, hover-bg),
border-color: map-get($map, hover-border-color),
box-shadow: map-get($map, hover-box-shadow),
color: map-get($map, hover-color),
),
map-get($map, hover)
background-color:
setter(
map-get($map, hover-bg),
map-get($hover, background-color)
),
border-color:
setter(
map-get($map, hover-border-color),
map-get($hover, border-color)
),
box-shadow:
setter(
map-get($map, hover-box-shadow),
map-get($hover, box-shadow)
),
color: setter(map-get($map, hover-color), map-get($hover, color)),
)
);

$focus: setter(map-get($map, focus), ());
$focus: map-deep-merge(
$focus,
(
background-color: map-get($map, focus-bg),
background-image: map-get($map, focus-bg-image),
border-color: map-get($map, focus-border-color),
box-shadow: map-get($map, focus-box-shadow),
color: map-get($map, focus-color),
),
map-get($map, focus)
background-color:
setter(
map-get($map, focus-bg),
map-get($focus, background-color)
),
background-image:
setter(
map-get($map, focus-bg-image),
map-get($focus, background-image)
),
border-color:
setter(
map-get($map, focus-border-color),
map-get($focus, border-color)
),
box-shadow:
setter(
map-get($map, focus-box-shadow),
map-get($focus, box-shadow)
),
color: setter(map-get($map, focus-color), map-get($focus, color)),
)
);

$disabled: setter(map-get($map, disabled), ());
$disabled: map-deep-merge(
$disabled,
(
background-color: map-get($map, disabled-bg),
background-image: map-get($map, disabled-bg-image),
border-color: map-get($map, disabled-border-color),
box-shadow: map-get($map, disabled-box-shadow),
color: map-get($map, disabled-color),
cursor: map-get($map, disabled-cursor),
opacity: map-get($map, disabled-opacity),
),
map-get($map, disabled)
background-color:
setter(
map-get($map, disabled-bg),
map-get($disabled, background-color)
),
background-image:
setter(
map-get($map, disabled-bg-image),
map-get($disabled, background-image)
),
border-color:
setter(
map-get($map, disabled-border-color),
map-get($disabled, border-color)
),
box-shadow:
setter(
map-get($map, disabled-box-shadow),
map-get($disabled, box-shadow)
),
color:
setter(map-get($map, disabled-color), map-get($disabled, color)),
cursor:
setter(
map-get($map, disabled-cursor),
map-get($disabled, cursor)
),
opacity:
setter(
map-get($map, disabled-opacity),
map-get($disabled, opacity)
),
)
);

$disabled-option: setter(map-get($disabled, option), ());
$disabled-option: map-deep-merge(
$disabled-option,
(
color: map-get($map, disabled-color),
),
map-get($map, disabled-option)
color:
setter(
map-get($map, disabled-color),
map-get($disabled-option, color)
),
)
);

$option: map-deep-merge((), map-get($map, option));
$option: setter(map-get($map, option), ());

@if ($enabled) {
@include clay-css($base);
Expand Down
1 change: 0 additions & 1 deletion packages/clay-css/src/scss/variables/_date-picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ $date-picker-nav-btn-monospaced: map-deep-merge(
);

$date-picker-nav-select: () !default;
$date-picker-nav-select: map-deep-merge((), $date-picker-nav-select);
Comment on lines 53 to -54
Copy link
Member

Choose a reason for hiding this comment

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

Just a question about the unrelated this change:

  • Double declaration in sequence: the last declaration rewrite the last declaration, right? why double declaration?
  • Once you removed the last declaration, what's the expected side effect? if it exist, of course.

Copy link
Member Author

@pat270 pat270 May 17, 2021

Choose a reason for hiding this comment

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

@matuzalemsteles Not a problem, map-merge takes whatever was declared in the first map and combines the two. If there are two keys with the same name in both maps, whatever is declared in the second map wins between the two. This is a way (hack?) to provide default values with Sass maps.

An example that may help explain better:

// This one replaces `$map: () !default;` below it
$map: (
  background-color: #eee,
  color: red,
) !default;

$map: () !default;
$map: map-merge((
  color: black,
  font-size: 16px,
), $map);

// $map will be:
$map: (
  background-color: #eee,
  color: red,
  font-size: 16px,
);

If we don't use map-merge while providing default values:

$map: (
  background-color: #eee,
  color: red,
) !default;

$map: (
  color: black,
  font-size: 16px,
) !default;

// $map will be:
$map: (
  background-color: #eee,
  color: red,
);

The reason we don't need it here is because we aren't providing any default values for $date-picker-nav-select.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm makes sense, thanks for the clarification.


// Date Picker Row

Expand Down
6 changes: 3 additions & 3 deletions packages/clay-css/src/scss/variables/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,9 @@ $input-select: map-deep-merge(
),
disabled: (
background-image: $input-select-icon-disabled,
),
disabled-option: (
cursor: $disabled-cursor,
option: (
cursor: $disabled-cursor,
),
),
option: (
cursor: $input-select-cursor,
Expand Down