forked from carbon-design-system/carbon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_menu.scss
159 lines (132 loc) · 3.34 KB
/
_menu.scss
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//
// Copyright IBM Corp. 2020
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//
@use '../button/tokens' as button-tokens;
@use '../../config' as *;
@use '../../layer' as *;
@use '../../motion' as *;
@use '../../spacing' as *;
@use '../../theme' as *;
@use '../../type' as *;
@use '../../utilities/box-shadow' as *;
@use '../../utilities/focus-outline' as *;
@use '../../utilities/z-index' as *;
@use '../../utilities/convert';
@use '../../utilities/component-reset';
/// Menu styles
/// @access public
/// @group menu
@mixin menu {
// Menu
.#{$prefix}--menu {
@include component-reset.reset;
@include box-shadow;
position: fixed;
z-index: z('modal');
min-width: 10rem;
max-width: 18rem;
padding: $spacing-02 0;
background-color: $layer;
opacity: 0;
visibility: hidden;
}
.#{$prefix}--menu--with-icons {
min-width: 12rem;
}
.#{$prefix}--menu--open {
visibility: visible;
&:focus {
@include focus-outline('border');
}
}
.#{$prefix}--menu:not(.#{$prefix}--menu--open) .#{$prefix}--menu--open {
visibility: hidden;
}
.#{$prefix}--menu--shown {
opacity: 1;
}
// MenuItem
.#{$prefix}--menu-item {
@include type-style('body-short-01');
display: grid;
height: 2rem;
align-items: center;
color: $text-primary;
column-gap: $spacing-03;
cursor: pointer;
grid-template-columns: 1fr max-content;
padding-inline: $spacing-05;
transition: background-color $duration-fast-01 motion(standard, productive);
&:focus {
@include focus-outline('outline');
}
}
.#{$prefix}--menu-item:hover {
background-color: $layer-hover;
}
$supported-sizes: (
'xs': 1.5rem,
'sm': 2rem,
'md': 2.5rem,
'lg': 3rem,
);
@each $size, $value in $supported-sizes {
.#{$prefix}--menu--#{$size} .#{$prefix}--menu-item {
height: $value;
}
}
.#{$prefix}--menu-item__icon {
display: none;
}
.#{$prefix}--menu--with-icons .#{$prefix}--menu-item__icon {
display: flex;
}
.#{$prefix}--menu-item__label {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.#{$prefix}--menu-item__shortcut {
display: flex;
}
.#{$prefix}--menu-item-group > ul,
.#{$prefix}--menu-item-radio-group > ul {
@include component-reset.reset;
}
.#{$prefix}--menu--with-icons > .#{$prefix}--menu-item,
.#{$prefix}--menu--with-icons
> .#{$prefix}--menu-item-group
> ul
> .#{$prefix}--menu-item,
.#{$prefix}--menu--with-icons
> .#{$prefix}--menu-item-radio-group
> ul
> .#{$prefix}--menu-item {
grid-template-columns: 1rem 1fr max-content;
}
.#{$prefix}--menu-item--disabled {
color: $text-disabled;
cursor: not-allowed;
}
.#{$prefix}--menu-item--disabled:hover,
.#{$prefix}--menu-item--disabled.#{$prefix}--menu-item--danger:hover {
background-color: $layer;
color: $text-disabled;
}
.#{$prefix}--menu-item--danger:focus,
.#{$prefix}--menu-item--danger:hover {
background-color: button-tokens.$button-danger-primary;
color: $text-on-color;
}
// MenuItemDivider
.#{$prefix}--menu-item-divider {
display: block;
width: 100%;
height: convert.to-rem(1px);
background-color: $border-subtle;
margin-block: $spacing-02;
}
}