summaryrefslogtreecommitdiffstats
path: root/src/objects/_field-label.scss
blob: 341bf496df7335cab5c27c5fe005a98061d01c60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
@use 'iro-sass/src/index' as iro;
@use '../vars';
@use '../mixins/typography';

@include iro.props-namespace('field-label') {
    @include iro.props-store((
        --dims: (
            --spacing-x:       iro.props-get(--dims --spacing --x --sm, $global: true),
            --spacing-y:       iro.props-get(--dims --spacing --y --xs, $global: true),
            --label-font-size: iro.props-get(--dims --font-size --sm, $global: true),
            --hint-font-size:  iro.props-get(--dims --font-size --sm, $global: true),
        ),
        --colors: (
            --label:      iro.props-get(--colors --fg-hi, $global: true),
            --hint:       iro.props-get(--colors --fg, $global: true),
            --error-hint: iro.props-get(--colors --accent --error, $global: true),
            --disabled:   iro.props-get(--colors --fg-hi3, $global: true),
        ),
    ));

    @include iro.bem-object(iro.props-namespace()) {
        display: inline-block;

        @include iro.bem-elem('label') {
            display:       block;
            padding-right: iro.props-get(--dims --spacing-x);
            color:         iro.props-get(--colors --label);
            font-size:     iro.props-get(--dims --label-font-size);
            font-weight:   400;
            line-height:   1.3;
    
            @include iro.bem-next-elem('content') {
                margin-top: iro.props-get(--dims --spacing-y);
            }
        }
    
        @include iro.bem-elem('content') {
            display: inline-block;
        }
    
        @include iro.bem-elem('hint') {
            display:    block;
            margin-top: iro.props-get(--dims --spacing-y);
            color:      iro.props-get(--colors --hint);
            font-size:  iro.props-get(--dims --hint-font-size);
        }
    
        @include iro.bem-is('invalid') {
            @include iro.bem-elem('hint') {
                color: iro.props-get(--colors --error-hint);
            }
        }
    
        @include iro.bem-is('disabled') {
            @include iro.bem-elem('label', 'hint') {
                color: iro.props-get(--colors --disabled);
            }
        }
    
        @include iro.bem-modifier('left', 'right') {
            display:     inline-flex;
            align-items: baseline;
    
            @include iro.bem-elem('label') {
                display: inline-block;
    
                @include iro.bem-next-elem('content') {
                    margin-top: 0;
                }
            }
        }
    
        @include iro.bem-modifier('left') {
            @include iro.bem-elem('label') {
                text-align: left;
            }
        }
    
        @include iro.bem-modifier('right') {
            @include iro.bem-elem('label') {
                text-align: right;
            }
        }
    }
}