Skip to content

Commit 7c2c92e

Browse files
authored
label - update the label directive styles to use typography styles. (#14667)
1 parent 75d0b67 commit 7c2c92e

File tree

11 files changed

+150
-16
lines changed

11 files changed

+150
-16
lines changed

projects/igniteui-angular/src/lib/core/styles/components/input/_input-group-theme.scss

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -910,10 +910,14 @@
910910
}
911911
}
912912

913-
%form-group-label--float {
914-
--floating-label-position: -73%;
915-
transform: translateY(var(--floating-label-position));
916-
font-size: rem(12px);
913+
@if $variant == 'material' {
914+
%form-group-label--float {
915+
--floating-label-position: -73%;
916+
917+
@include type-style('caption');
918+
919+
transform: translateY(var(--floating-label-position));
920+
}
917921
}
918922

919923
%form-group-label--focused-border,
@@ -972,8 +976,8 @@
972976

973977
%form-group-label--float-border {
974978
--label-position: #{sizable(18px, 22px, 26px)};
979+
975980
transform: translateY(calc(var(--label-position) * -1));
976-
font-size: rem(12px);
977981
margin-top: 0;
978982
overflow: hidden;
979983
will-change: font-size, color, transform;
@@ -1718,8 +1722,6 @@
17181722
// Label
17191723
%fluent-label {
17201724
display: block;
1721-
font-size: rem(14px);
1722-
font-weight: 600;
17231725
position: static;
17241726
transform: translateY(0);
17251727
transform-origin: top left;
@@ -1939,13 +1941,11 @@
19391941
display: block;
19401942
color: var-get($theme, 'idle-secondary-color');
19411943
padding: 0;
1942-
line-height: rem(24px);
19431944
transform: translateY(0);
19441945
transform-origin: top left;
19451946
margin-block-start: 0 !important;
19461947
margin-block-end: rem(4px);
19471948
height: auto;
1948-
font-size: rem(16px);
19491949

19501950
[dir='rtl'] & {
19511951
transform-origin: top right;

projects/igniteui-angular/src/lib/core/styles/components/label/_label-theme.scss

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,33 @@
5050
color: var-get($theme, 'color');
5151
max-width: 100%;
5252
line-height: normal;
53-
font-size: rem(16px);
5453

5554
[dir='rtl'] & {
5655
transform-origin: top right;
5756
}
5857

59-
@if $variant == 'fluent' or $variant == 'indigo-design' {
60-
font-size: rem(14px);
61-
font-weight: 600;
58+
@if $variant != 'material' {
6259
height: auto;
6360
}
61+
}
62+
}
6463

65-
@if $variant == 'bootstrap' {
66-
line-height: rem(24px);
67-
height: auto;
64+
/// Adds typography styles for the igx-label component.
65+
/// Uses the 'caption'
66+
/// category from the typographic scale.
67+
/// @group typography
68+
/// @param {Map} $categories [(label: 'caption')] - The categories from the typographic scale used for type styles.
69+
@mixin label-typography(
70+
$categories: (
71+
label: 'subtitle-1',
72+
)
73+
) {
74+
$label: map.get($categories, 'label');
75+
76+
%label-base {
77+
@include type-style($label) {
78+
margin: 0;
6879
}
6980
}
7081
}
82+

projects/igniteui-angular/src/lib/core/styles/typography/_bootstrap.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
@use '../components/toast/toast-theme' as *;
3131
@use '../components/tooltip/tooltip-theme' as *;
3232
@use '../components/tree/tree-theme' as *;
33+
@use '../components/label/label-theme' as *;
3334

3435
@mixin typography($type-scale) {
3536
@include badge-typography();
@@ -108,4 +109,7 @@
108109
@include toast-typography();
109110
@include tooltip-typography();
110111
@include tree-typography();
112+
@include label-typography($categories: (
113+
label: 'body-1'
114+
));
111115
}

projects/igniteui-angular/src/lib/core/styles/typography/_fluent.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
@use '../components/toast/toast-theme' as *;
3030
@use '../components/tooltip/tooltip-theme' as *;
3131
@use '../components/tree/tree-theme' as *;
32+
@use '../components/label/label-theme' as *;
3233

3334
@mixin typography() {
3435
@include badge-typography();
@@ -104,4 +105,7 @@
104105
));
105106
@include tooltip-typography();
106107
@include tree-typography();
108+
@include label-typography($categories: (
109+
label: 'subtitle-2'
110+
));
107111
}

projects/igniteui-angular/src/lib/core/styles/typography/_indigo.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
@use '../components/toast/toast-theme' as *;
3030
@use '../components/tooltip/tooltip-theme' as *;
3131
@use '../components/tree/tree-theme' as *;
32+
@use '../components/label/label-theme' as *;
3233

3334
@mixin typography() {
3435
@include badge-typography($categories: (
@@ -109,4 +110,7 @@
109110
@include toast-typography();
110111
@include tooltip-typography();
111112
@include tree-typography();
113+
@include label-typography($categories: (
114+
label: 'caption'
115+
));
112116
}

projects/igniteui-angular/src/lib/core/styles/typography/_material.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
@use '../components/toast/toast-theme' as *;
3030
@use '../components/tooltip/tooltip-theme' as *;
3131
@use '../components/tree/tree-theme' as *;
32+
@use '../components/label/label-theme' as *;
3233

3334
@mixin typography() {
3435
@include badge-typography();
@@ -62,4 +63,5 @@
6263
@include toast-typography();
6364
@include tooltip-typography();
6465
@include tree-typography();
66+
@include label-typography();
6567
}

src/app/app.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,11 @@ export class AppComponent implements OnInit {
656656
link: '/virtualForDirective',
657657
icon: 'view_column',
658658
name: 'Virtual-For Directive'
659+
},
660+
{
661+
link: '/labelDirective',
662+
icon: 'label',
663+
name: 'Label Directive'
659664
}
660665
].sort((componentLink1, componentLink2) => componentLink1.name > componentLink2.name ? 1 : -1);
661666

src/app/app.routes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ import { GridValidationSampleComponent } from './grid-validation/grid-validation
138138
import { GridExportComponent } from './grid-export/grid-export.sample';
139139
import { DividerComponent } from './divider/divider.component';
140140
import { MonthPickerSampleComponent } from './month-picker/month-picker.sample';
141+
import { LabelSampleComponent } from "./label/label.sample";
141142

142143
export const appRoutes: Routes = [
143144
{
@@ -664,5 +665,9 @@ export const appRoutes: Routes = [
664665
{
665666
path: 'stepper',
666667
component: StepperSampleComponent
668+
},
669+
{
670+
path: 'labelDirective',
671+
component: LabelSampleComponent
667672
}
668673
];

src/app/label/label.sample.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<div class="form-container">
2+
<span>Igx Label on native form elements</span>
3+
4+
<form>
5+
<div>
6+
<label for="text_field" igxLabel>Input</label>
7+
<input id="text_field" type="text">
8+
</div>
9+
10+
<section>
11+
<input id="check_box" type="checkbox">
12+
<label for="check_box" igxLabel>Checkbox</label>
13+
</section>
14+
15+
<div>
16+
<div>
17+
<input id="one" type="radio" name="count" checked>
18+
<label for="one" igxLabel>Radio one</label>
19+
</div>
20+
21+
<div>
22+
<input id="two" type="radio" name="count">
23+
<label for="two" igxLabel>Radio two</label>
24+
</div>
25+
26+
<div>
27+
<input id="three" type="radio" name="count">
28+
<label for="three" igxLabel>Radio three</label>
29+
</div>
30+
</div>
31+
32+
<div>
33+
<label for="range" igxLabel>Range picker</label>
34+
<input id="range" type="range">
35+
</div>
36+
37+
<div>
38+
<label for="color" igxLabel>Color picker</label>
39+
<input id="color" type="color">
40+
</div>
41+
</form>
42+
</div>

src/app/label/label.sample.scss

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
%f-column {
2+
display: flex;
3+
flex-direction: column;
4+
}
5+
6+
.form-container {
7+
@extend %f-column;
8+
9+
gap: 24px;
10+
11+
form {
12+
@extend %f-column;
13+
14+
justify-content: center;
15+
gap: 24px;
16+
}
17+
18+
span {
19+
font-size: 24px;
20+
}
21+
22+
section {
23+
display: flex;
24+
gap: 6px;
25+
}
26+
27+
form > div {
28+
@extend %f-column;
29+
30+
align-items: flex-start;
31+
justify-content: center;
32+
gap: 8px;
33+
34+
div {
35+
display: flex;
36+
gap: 6px;
37+
}
38+
}
39+
40+
input {
41+
margin: 0;
42+
}
43+
}

0 commit comments

Comments
 (0)