Skip to content

Commit abb50df

Browse files
authored
fix(radio): prevent circles distraction (#1549)
1 parent ae73257 commit abb50df

File tree

3 files changed

+37
-34
lines changed

3 files changed

+37
-34
lines changed

src/framework/theme/components/radio/_radio.component.theme.scss

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,81 +6,84 @@
66

77
@mixin nb-radio-theme() {
88
nb-radio {
9-
.radio-circle {
9+
.outer-circle,
10+
.inner-circle {
1011
height: nb-theme(radio-height);
1112
width: nb-theme(radio-width);
13+
}
14+
15+
.outer-circle {
1216
background-color: nb-theme(radio-background-color);
1317
border-color: nb-theme(radio-border-color);
1418
border-style: nb-theme(radio-border-style);
1519
border-width: nb-theme(radio-border-width);
1620
}
1721

18-
.native-input:enabled:checked + .radio-circle {
22+
.native-input:enabled:checked + .outer-circle {
1923
border-color: nb-theme(radio-primary-border-color);
20-
21-
&::before {
22-
background-color: nb-theme(radio-primary-inner-circle-color);;
23-
}
24+
}
25+
.native-input:enabled:checked ~ .inner-circle {
26+
background-color: nb-theme(radio-primary-inner-circle-color);;
2427
}
2528

26-
.native-input:enabled:focus + .radio-circle {
29+
.native-input:enabled:focus + .outer-circle {
2730
border-color: nb-theme(radio-primary-focus-border-color);
2831
box-shadow: 0 0 0 nb-theme(radio-outline-width) nb-theme(radio-outline-color);
2932
}
30-
.native-input:enabled:checked:focus + .radio-circle::before {
33+
.native-input:enabled:checked:focus ~ .inner-circle {
3134
background-color: nb-theme(radio-primary-focus-inner-circle-color);
3235
}
3336

34-
label:hover .native-input:enabled + .radio-circle {
37+
label:hover .native-input:enabled + .outer-circle {
3538
border-color: nb-theme(radio-primary-hover-border-color);
3639
}
37-
label:hover .native-input:checked:enabled + .radio-circle::before {
40+
label:hover .native-input:checked:enabled ~ .inner-circle {
3841
background-color: nb-theme(radio-primary-hover-inner-circle-color);
3942
}
4043

41-
label .native-input:enabled:active + .radio-circle {
44+
label .native-input:enabled:active + .outer-circle {
4245
border-color: nb-theme(radio-primary-active-border-color);
4346
}
44-
label .native-input:enabled:checked:active + .radio-circle::before {
47+
label .native-input:enabled:checked:active ~ .inner-circle {
4548
background-color: nb-theme(radio-primary-active-inner-circle-color);
4649
}
4750

48-
.native-input:disabled + .radio-circle {
51+
.native-input:disabled + .outer-circle {
4952
border-color: nb-theme(radio-disabled-border-color);
5053
}
51-
.native-input:disabled:checked + .radio-circle::before {
54+
.native-input:disabled:checked ~ .inner-circle {
5255
background-color: nb-theme(radio-disabled-inner-circle-color);
5356
}
5457
.native-input:disabled ~ .text {
5558
color: nb-theme(radio-disabled-text-color);
5659
}
5760

5861
@each $status in nb-get-statuses() {
59-
&.status-#{$status} .native-input:enabled + .radio-circle {
62+
&.status-#{$status} .native-input:enabled + .outer-circle {
6063
border-color: nb-theme(radio-#{$status}-border-color);
6164
}
62-
&.status-#{$status} .native-input:enabled:checked + .radio-circle::before {
65+
&.status-#{$status} .native-input:enabled:checked ~ .inner-circle {
6366
background-color: nb-theme(radio-#{$status}-inner-circle-color);;
6467
}
6568

66-
&.status-#{$status} .native-input:enabled:focus + .radio-circle {
69+
&.status-#{$status} .native-input:enabled:focus + .outer-circle {
6770
border-color: nb-theme(radio-#{$status}-focus-border-color);
6871
}
69-
&.status-#{$status} .native-input:enabled:checked:focus + .radio-circle::before {
72+
&.status-#{$status} .native-input:enabled:checked:focus ~ .inner-circle {
7073
background-color: nb-theme(radio-#{$status}-focus-inner-circle-color);
7174
}
7275

73-
&.status-#{$status} label:hover .native-input:enabled + .radio-circle {
76+
&.status-#{$status} label:hover .native-input:enabled + .outer-circle {
7477
border-color: nb-theme(radio-#{$status}-hover-border-color);
7578
}
76-
&.status-#{$status} label:hover .native-input:checked:enabled + .radio-circle::before {
79+
&.status-#{$status} label:hover .native-input:checked:enabled ~ .inner-circle {
7780
background-color: nb-theme(radio-#{$status}-hover-inner-circle-color);
7881
}
7982

80-
&.status-#{$status} label .native-input:enabled:active + .radio-circle {
83+
&.status-#{$status} label .native-input:enabled:active + .outer-circle {
8184
border-color: nb-theme(radio-#{$status}-active-border-color);
8285
}
83-
&.status-#{$status} label .native-input:enabled:checked:active + .radio-circle::before {
86+
&.status-#{$status} label .native-input:enabled:checked:active ~ .inner-circle {
8487
background-color: nb-theme(radio-#{$status}-active-inner-circle-color);
8588
}
8689
}
@@ -91,6 +94,7 @@
9194
font-size: nb-theme(radio-text-font-size);
9295
font-weight: nb-theme(radio-text-font-weight);
9396
line-height: nb-theme(radio-text-line-height);
97+
margin-left: nb-theme(radio-width);
9498
}
9599
}
96100
}

src/framework/theme/components/radio/radio.component.scss

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
:host {
1010
display: block;
11+
position: relative;
1112

1213
label {
1314
display: inline-flex;
@@ -17,20 +18,17 @@
1718
align-items: center;
1819
}
1920

20-
.radio-circle {
21+
.outer-circle,
22+
.inner-circle {
2123
border-radius: 50%;
22-
border-style: solid;
23-
flex-shrink: 0;
24-
display: flex;
25-
justify-content: center;
26-
align-items: center;
24+
position: absolute;
25+
top: 50%;
26+
left: 0;
27+
transform: translateY(-50%);
2728
}
2829

29-
.radio-circle::before {
30-
content: '';
31-
border-radius: 50%;
32-
height: 75%;
33-
width: 75%;
30+
.inner-circle {
31+
transform: translateY(-50%) scale(0.65);
3432
}
3533

3634
.text {

src/framework/theme/components/radio/radio.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ import { NbComponentStatus } from '../component-status';
126126
[disabled]="disabled"
127127
(change)="onChange($event)"
128128
(click)="onClick($event)">
129-
<span class="radio-circle"></span>
129+
<span class="outer-circle"></span>
130+
<span class="inner-circle"></span>
130131
<span class="text">
131132
<ng-content></ng-content>
132133
</span>

0 commit comments

Comments
 (0)