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

chore: Migrate Button component to logical properties #1729

Merged
merged 6 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,17 @@
}
]
},
"overrides": [
{
"files": ["./src/button/*.scss"],
"rules": {
"property-disallowed-list": ["border", "border-radius", "border-style", "margin", "padding"],
"csstools/use-logical": "always"
}
}
],
"plugins": [
"stylelint-use-logical",
"stylelint-order",
"stylelint-no-unsupported-browser-features",
"./build-tools/stylelint"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@
"rollup-plugin-license": "^3.0.1",
"sass": "^1.43.4",
"sass-loader": "^12.3.0",
"stylelint": "^15.10.1",
"stylelint": "^15.11.0",
"stylelint-config-prettier": "^9.0.4",
"stylelint-config-recommended-scss": "^12.0.0",
"stylelint-no-unsupported-browser-features": "^7.0.0",
"stylelint-order": "^6.0.3",
"stylelint-prettier": "^2.0.0",
"stylelint-scss": "^5.0.1",
"stylelint-use-logical": "^2.1.0",
"svgo": "^2.8.0",
"ts-jest": "^28.0.2",
"ts-loader": "^9.2.6",
Expand Down
51 changes: 29 additions & 22 deletions src/button/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
border-width: map.get($variant, 'border-width');
position: relative;
text-decoration: none;
padding: map.get($variant, 'padding');
padding-block: map.get($variant, 'padding');
padding-inline: map.get($variant, 'padding');
font-weight: map.get($variant, 'font-weight');

&:hover {
Expand Down Expand Up @@ -78,9 +79,14 @@
@include styles.text-wrapping;
@include styles.font-button;
letter-spacing: awsui.$font-button-letter-spacing;
border-radius: awsui.$border-radius-button;
border: styles.$control-border-width solid;
padding: styles.$control-padding-vertical awsui.$space-button-horizontal;
border-start-start-radius: awsui.$border-radius-button;
border-start-end-radius: awsui.$border-radius-button;
border-end-start-radius: awsui.$border-radius-button;
border-end-end-radius: awsui.$border-radius-button;
border-block: styles.$control-border-width solid;
border-inline: styles.$control-border-width solid;
padding-block: styles.$control-padding-vertical;
padding-inline: awsui.$space-button-horizontal;
display: inline-block; // for <a> as a button
text-decoration: none;
cursor: pointer;
Expand All @@ -92,16 +98,16 @@
}

&.button-no-text {
padding-left: awsui.$space-button-icon-only-horizontal;
padding-right: awsui.$space-button-icon-only-horizontal;
padding-inline-start: awsui.$space-button-icon-only-horizontal;
padding-inline-end: awsui.$space-button-icon-only-horizontal;
}

&.button-no-wrap {
white-space: nowrap;
}

&.full-width {
width: 100%;
inline-size: 100%;
text-align: center;
}

Expand All @@ -110,40 +116,41 @@
&.variant-flashbar-icon {
// Icon has vertical padding, but no horizontal, we need to conpensate this
// in order to have equal height and width
padding-left: awsui.$space-xxs;
padding-right: awsui.$space-xxs;
padding-inline-start: awsui.$space-xxs;
padding-inline-end: awsui.$space-xxs;
}

&.variant-modal-dismiss {
padding: awsui.$space-button-modal-dismiss-vertical awsui.$space-xxs;
margin-right: calc(-1 * #{awsui.$space-xxs});
padding-block: awsui.$space-button-modal-dismiss-vertical;
padding-inline: awsui.$space-xxs;
margin-inline-end: calc(-1 * #{awsui.$space-xxs});
}

&.variant-inline-icon {
padding-top: 0;
padding-bottom: 0;
border: 0;
padding-block-start: 0;
padding-block-end: 0;
border-block: 0;
border-inline: 0;
}

> .icon-left {
position: relative;
// margin-left was breaking layout on firefox
left: calc(-1 * #{awsui.$space-xxs});
margin-right: awsui.$space-xxs;
inset-inline-start: calc(-1 * #{awsui.$space-xxs});
margin-inline-end: awsui.$space-xxs;
}

> .icon-right {
position: relative;
// margin-right was breaking layout on firefox
right: calc(-1 * #{awsui.$space-xxs});
margin-left: awsui.$space-xxs;
inset-inline-end: calc(-1 * #{awsui.$space-xxs});
margin-inline-start: awsui.$space-xxs;
}

&.button-no-text > .icon {
margin-right: auto;
margin-left: auto;
margin-inline-start: auto;
margin-inline-end: auto;
// IE does not understand `initial`
right: 0;
left: 0;
inset-inline: 0;
}
}
Loading