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: radio and checkbox button RTL alignments #753

Merged
merged 2 commits into from
Mar 4, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ $block: #{$fd-namespace}-checkbox;
display: flex;
align-items: center;

@include fd-rtl() {
padding: $fd-checkbox-margin $fd-checkbox-margin $fd-checkbox-margin 0;
}

&::before {
content: "";
height: $fd-checkbox-dimensions;
Expand All @@ -60,11 +64,19 @@ $block: #{$fd-namespace}-checkbox;
font-family: "SAP-icons";
background-color: var(--sapField_Background);
margin-right: $fd-checkbox-margin;
margin-left: 0;
color: var(--sapSelectedColor);
border: var(--sapField_BorderWidth) solid var(--sapField_BorderColor);
border-radius: var(--sapField_BorderCornerRadius);
}

@include fd-rtl() {
&::before {
margin-left: $fd-checkbox-margin;
margin-right: 0;
}
}

@include fd-hover() {
&::before {
background-color: var(--sapField_Hover_Background);
Expand Down Expand Up @@ -129,12 +141,24 @@ $block: #{$fd-namespace}-checkbox;
+ .#{$block}__label {
padding: $fd-checkbox-margin-compact 0 $fd-checkbox-margin-compact $fd-checkbox-margin-compact;

@include fd-rtl() {
padding: $fd-checkbox-margin-compact $fd-checkbox-margin-compact $fd-checkbox-margin-compact 0;
}

&::before {
font-size: 0.625rem;
height: $fd-checkbox-dimensions-compact;
width: $fd-checkbox-dimensions-compact;
min-width: $fd-checkbox-dimensions-compact;
margin-right: $fd-checkbox-margin-compact;
margin-left: 0;
}

@include fd-rtl() {
&::before {
margin-left: $fd-checkbox-margin-compact;
margin-right: 0;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/mixins/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@

@include fd-rtl() {
&::after {
left: $fd-radio-label-padding - $fd-radio-focus-offset;
left: $fd-radio-label-padding;
right: $margin - $fd-radio-focus-offset;
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ $block: #{$fd-namespace}-radio;
overflow: hidden;
padding: $fd-radio-outer-circle-margin 0 $fd-radio-outer-circle-margin $fd-radio-outer-circle-margin;

@include fd-rtl() {
padding: $fd-radio-outer-circle-margin $fd-radio-outer-circle-margin $fd-radio-outer-circle-margin 0;
}

&::before {
content: "";
height: $fd-radio-inner-circle-diameter;
Expand All @@ -72,6 +76,13 @@ $block: #{$fd-namespace}-radio;
border-color: var(--sapField_Hover_BorderColor);
}
}

@include fd-rtl() {
&::before {
margin-left: $fd-radio-outer-circle-margin;
margin-right: 0;
}
}
}

&:checked + .#{$block}__label::before {
Expand Down Expand Up @@ -120,12 +131,24 @@ $block: #{$fd-namespace}-radio;
+ .#{$block}__label {
padding: $fd-radio-outer-circle-margin-compact 0 $fd-radio-outer-circle-margin-compact $fd-radio-outer-circle-margin-compact;

@include fd-rtl() {
padding: $fd-radio-outer-circle-margin-compact $fd-radio-outer-circle-margin-compact $fd-radio-outer-circle-margin-compact 0;
}

&::before {
font-size: 0.4375rem;
height: $fd-radio-inner-circle-diameter-compact;
width: $fd-radio-inner-circle-diameter-compact;
min-width: $fd-radio-inner-circle-diameter-compact;
margin-right: $fd-radio-outer-circle-margin-compact;
margin-left: 0;
}

@include fd-rtl() {
&::before {
margin-left: $fd-radio-outer-circle-margin-compact;
margin-right: 0;
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions test/templates/checkbox/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,17 @@
{{ checkbox(compact=true, properties='checked') }}
{% endset %}

{{ format(example) }}

<h2>RTL mode</h2>
{% set example %}
<div dir="RTL">
{{ checkbox(compact=true) }}
{{ checkbox(compact=true, properties='checked') }}
{{ checkbox(compact=false) }}
{{ checkbox(compact=false, properties='checked') }}
</div>
{% endset %}

{{ format(example) }}
{% endblock %}
13 changes: 13 additions & 0 deletions test/templates/radio/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,18 @@
{{ radio(compact=true, properties='checked') }}
{% endset %}

{{ format(example) }}

<h2>RTL</h2>

{% set example %}
<div dir="RTL">
{{ radio(compact=true) }}
{{ radio(compact=true, properties='checked') }}
{{ radio(compact=false) }}
{{ radio(compact=false, properties='checked') }}
</div>
{% endset %}

{{ format(example) }}
{% endblock %}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.