Commit 836adf88 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Restructure common buttons SASS modules and make `reset` mixin public

parent 8b17791a
@use './components/buttons'; @use './components/buttons/styles';
@use "sass:map"; @use "sass:map";
@use "@hypothesis/frontend-shared/styles/mixins/focus";
// Set colors for a button // Set colors for a button
@mixin _colors($colormap) { @mixin _colors($colormap) {
color: map.get($colormap, 'foreground'); color: map.get($colormap, 'foreground');
...@@ -53,13 +51,6 @@ ...@@ -53,13 +51,6 @@
// Base mixin for buttons. // Base mixin for buttons.
@mixin button($options) { @mixin button($options) {
// Reset browser defaults
@include focus.outline-on-keyboard-focus;
padding: 0;
margin: 0;
background-color: transparent;
border-style: none;
@include _colors(map.get($options, 'colormap')); @include _colors(map.get($options, 'colormap'));
@if map.get($options, 'withStates') { @if map.get($options, 'withStates') {
......
@use './mixins'; @forward 'config';
@forward 'mixins';
// A button with text, and optionally an icon
.LabeledButton {
@include mixins.LabeledButton;
}
// A button with only an icon and no label/text
.IconButton {
@include mixins.IconButton;
}
// A button styled to appear as a link, with underline on hover
.LinkButton {
@include mixins.LinkButton;
}
...@@ -2,11 +2,17 @@ ...@@ -2,11 +2,17 @@
@use "@hypothesis/frontend-shared/styles/mixins/focus"; @use "@hypothesis/frontend-shared/styles/mixins/focus";
@use './_config' as c; @use 'config' as c;
@use './_base' as base; @use 'base';
// Allow access to the configuration values to users of this module (esp. colors) // Basic reset for browser-imposed button styles
@forward './_config'; @mixin reset {
@include focus.outline-on-keyboard-focus;
padding: 0;
margin: 0;
background-color: transparent;
border-style: none;
}
// Base mixin for <button> elements // Base mixin for <button> elements
@mixin Button($options: ()) { @mixin Button($options: ()) {
...@@ -33,6 +39,7 @@ ...@@ -33,6 +39,7 @@
); );
$-options: map.merge($defaultOptions, $options); $-options: map.merge($defaultOptions, $options);
@include reset;
@include base.button($options: $-options); @include base.button($options: $-options);
// Add styles for supported variants as modifier classes, if `withVariants` enabled // Add styles for supported variants as modifier classes, if `withVariants` enabled
......
@use 'mixins';
// A button with text, and optionally an icon
.LabeledButton {
@include mixins.LabeledButton;
}
// A button with only an icon and no label/text
.IconButton {
@include mixins.IconButton;
}
// A button styled to appear as a link, with underline on hover
.LinkButton {
@include mixins.LinkButton;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
@use '../variables' as var; @use '../variables' as var;
// Button styling for the sidebar extending common button-component styles // Button styling for the sidebar extending common button-component styles
@use '../shared/components/buttons/mixins' as buttons; @use '../shared/components/buttons';
// Similar to `.LinkButton`, with inline layout (so button can be used // Similar to `.LinkButton`, with inline layout (so button can be used
// within text) // within text)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment