Skip to content

Commit

Permalink
Add icon buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahiss committed Nov 28, 2024
1 parent c6f5314 commit 2bce01c
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 129 deletions.
48 changes: 27 additions & 21 deletions scss/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
--#{$prefix}btn-box-shadow: #{$btn-box-shadow};
--#{$prefix}btn-disabled-opacity: #{$btn-disabled-opacity}; // TODO to check
--#{$prefix}btn-focus-box-shadow: 0 0 0 #{$btn-focus-width} var(--#{$prefix}btn-focus-shadow-rgb); // OUDS mod
--#{$prefix}icon-spacing: #{$btn-icon-padding-x}; // OUDS mod TODO to check
--#{$prefix}icon-spacing: #{$btn-icon-padding-left}; // OUDS mod TODO to check
// scss-docs-end btn-css-vars

display: inline-block;
Expand Down Expand Up @@ -83,6 +83,7 @@
// OUDS mod: no `.btn-check:checked:focus-visible + &` to handle box shadow

// OUDS mod: selectors are slightly different to handle `.btn-check`
// TODO how to handle to disable links with aria-disabled only
.btn-check:disabled + &,
&:disabled,
&.disabled,
Expand All @@ -97,11 +98,14 @@
}
// End mod

// OUDS mod: with icon
&:not(.btn-icon) > svg {
transform: translateY(1px);
&:not(.btn-icon) > svg,
&:not(.btn-icon) > img,
&:not(.btn-icon) > .bm-short-icon {
@extend .bm-short-icon;
margin-right: $ouds-button-space-column-gap-icon;
margin-left: subtract(var(--#{$prefix}icon-spacing), var(--#{$prefix}btn-padding-x));
vertical-align: text-bottom;
}
// End mod
}


Expand Down Expand Up @@ -211,15 +215,11 @@
}
}

@each $color, $value in $theme-colors {
.btn-outline-#{$color} {
$btn-outline-hover-color: var(--#{$prefix}highlight-color);
@if index(("primary", "warning", "light"), #{$color}) {
$btn-outline-hover-color: $black;
} @else if (#{$color} == "dark") {
$btn-outline-hover-color: $white;
@if $enable-bootstrap-compatibility { // OUDS mod
@each $color, $value in $theme-colors {
.btn-outline-#{$color} {
@extend .btn-default; // OUDS mod
}
@include button-outline-variant(var(--#{$prefix}#{$color}), $btn-outline-hover-color);
}
}
// scss-docs-end btn-variant-loops
Expand Down Expand Up @@ -321,18 +321,24 @@
// OUDS mod: 6th argument to set .btn-icon padding
// OUDS mod: 7th argument to set .btn-letter-spacing

.btn-lg {
@include button-size($btn-padding-y-lg, $btn-padding-x-lg, $btn-font-size-lg, $btn-border-radius-lg, $btn-line-height-lg, $btn-icon-padding-x-lg, $btn-letter-spacing-lg);
}

.btn-sm {
@include button-size($btn-padding-y-sm, $btn-padding-x-sm, $btn-font-size-sm, $btn-border-radius-sm, $btn-line-height-sm, $btn-icon-padding-x-sm, $btn-letter-spacing-sm);
}
//.btn-lg {
// @include button-size($btn-padding-y-lg, $btn-padding-x-lg, $btn-font-size-lg, $btn-border-radius-lg, $btn-line-height-lg, $btn-icon-padding-x-lg, $btn-letter-spacing-lg);
//}
//
//.btn-sm {
// @include button-size($btn-padding-y-sm, $btn-padding-x-sm, $btn-font-size-sm, $btn-border-radius-sm, $btn-line-height-sm, $btn-icon-padding-x-sm, $btn-letter-spacing-sm);
//}


// OUDS mod: icon button
.btn-icon {
padding: var(--#{$prefix}icon-spacing);
--#{$prefix}btn-padding-x: #{$ouds-button-space-inset-icon-alone};

> svg,
> img,
> .bm-medium-icon {
@extend .bm-medium-icon;
}
}
// End mod

Expand Down
9 changes: 5 additions & 4 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,10 @@ $btn-transition: $transition-focus !default; // OUDS mod
// scss-docs-end btn-variables

// OUDS mod: icon button
$btn-icon-padding-x: subtract($spacer * .5, var(--#{$prefix}border-width)) !default;
$btn-icon-padding-x-sm: $spacer * .25 !default;
$btn-icon-padding-x-lg: add($spacer * .5, calc(var(--#{$prefix}border-width) * 1.5)) !default; // stylelint-disable-line function-disallowed-list
$btn-icon-padding-x: subtract($ouds-button-space-padding-inline-icon-start, var(--#{$prefix}border-width)) !default;
$btn-icon-padding-left: $ouds-button-space-padding-inline-icon-start !default;
// TODO to confirm to delete $btn-icon-padding-x-sm: $spacer * .25 !default;
// TODO to confirm to delete $btn-icon-padding-x-lg: add($spacer * .5, calc(var(--#{$prefix}border-width) * 1.5)) !default; // stylelint-disable-line function-disallowed-list
// OUDS mod: social button
// scss-docs-start social-buttons
$btn-social-networks: (
Expand Down Expand Up @@ -2296,7 +2297,7 @@ $quantity-selector-width: 7.5rem !default;
$quantity-selector-sm-width: 5.625rem !default;

$quantity-selector-btn-padding-x: add($btn-icon-padding-x, 2px) !default;
$quantity-selector-btn-padding-x-sm: add($btn-icon-padding-x-sm, 2px) !default;
$quantity-selector-btn-padding-x-sm: add($btn-icon-padding-x, 2px) !default;
$quantity-selector-btn-bg: var(--#{$prefix}body-bg) !default;
$quantity-selector-btn-border: var(--#{$prefix}border-width) solid var(--#{$prefix}color-border-emphasized) !default;

Expand Down
Loading

0 comments on commit 2bce01c

Please sign in to comment.