Skip to content

Commit 8434721

Browse files
committed
chore(menu): move common styles into core
1 parent c0e6f83 commit 8434721

File tree

2 files changed

+50
-38
lines changed

2 files changed

+50
-38
lines changed

src/lib/core/style/_menu-common.scss

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@import './variables';
2+
@import './elevation';
3+
@import './list-common';
4+
5+
/** The mixins below are shared between md-menu and md-select */
6+
7+
// menu width must be a multiple of 56px
8+
$md-menu-overlay-min-width: 112px !default; // 56 * 2
9+
$md-menu-overlay-max-width: 280px !default; // 56 * 5
10+
11+
$md-menu-item-height: 48px !default;
12+
$md-menu-font-size: 16px !default;
13+
$md-menu-side-padding: 16px !default;
14+
$md-menu-vertical-padding: 8px !default;
15+
16+
@mixin md-menu-base() {
17+
@include md-elevation(2);
18+
min-width: $md-menu-overlay-min-width;
19+
max-width: $md-menu-overlay-max-width;
20+
21+
overflow: auto;
22+
-webkit-overflow-scrolling: touch; // for momentum scroll on mobile
23+
24+
padding-top: $md-menu-vertical-padding;
25+
padding-bottom: $md-menu-vertical-padding;
26+
}
27+
28+
@mixin md-menu-item-base() {
29+
@include md-truncate-line();
30+
31+
display: flex;
32+
flex-direction: row;
33+
align-items: center;
34+
height: $md-menu-item-height;
35+
padding: 0 $md-menu-side-padding;
36+
37+
font-size: $md-menu-font-size;
38+
font-family: $md-font-family;
39+
text-align: start;
40+
text-decoration: none; // necessary to reset anchor tags
41+
42+
&[disabled] {
43+
cursor: default;
44+
}
45+
}

src/lib/menu/menu.scss

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,22 @@
11
// TODO(kara): update vars for desktop when MD team responds
22
// TODO(kara): animation for menu opening
3-
@import '../core/style/variables';
4-
@import '../core/style/elevation';
3+
54
@import '../core/style/button-common';
65
@import '../core/style/sidenav-common';
7-
@import '../core/style/list-common';
8-
9-
10-
// menu width must be a multiple of 56px
11-
$md-menu-overlay-min-width: 112px !default; // 56 * 2
12-
$md-menu-overlay-max-width: 280px !default; // 56 * 5
13-
14-
$md-menu-item-height: 48px !default;
15-
$md-menu-font-size: 16px !default;
16-
$md-menu-side-padding: 16px !default;
17-
$md-menu-vertical-padding: 8px !default;
6+
@import '../core/style/menu-common';
187

198
.md-menu-panel {
20-
@include md-elevation(2);
21-
min-width: $md-menu-overlay-min-width;
22-
max-width: $md-menu-overlay-max-width;
9+
@include md-menu-base();
2310

2411
// max height must be 100% of the viewport height + one row height
2512
max-height: calc(100vh + 48px);
26-
overflow: auto;
27-
-webkit-overflow-scrolling: touch; // for momentum scroll on mobile
28-
29-
padding-top: $md-menu-vertical-padding;
30-
padding-bottom: $md-menu-vertical-padding;
3113
}
3214

3315
[md-menu-item] {
3416
@include md-button-reset();
35-
@include md-truncate-line();
36-
37-
display: flex;
38-
flex-direction: row;
39-
align-items: center;
40-
height: $md-menu-item-height;
41-
padding: 0 $md-menu-side-padding;
42-
43-
font-size: $md-menu-font-size;
44-
font-family: $md-font-family;
45-
text-align: start;
46-
text-decoration: none; // necessary to reset anchor tags
47-
48-
&[disabled] {
49-
cursor: default;
50-
}
17+
@include md-menu-item-base();
5118
}
5219

5320
button[md-menu-item] {
5421
width: 100%;
55-
}
22+
}

0 commit comments

Comments
 (0)