-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(drawer): custom sass mixins for color, background, scrim #1730
Changes from 14 commits
792e833
4f57a8a
c6c6bba
b6907f9
177bc40
957f4da
a4ee956
cf45316
702a755
a23155d
9c1df2d
f5072fd
559b464
b3251f9
dfa4b7c
d41685c
1907002
e79edea
989b7d4
6e1c6a1
503c2ae
336d123
1815681
b6ff3eb
09f1532
8a43447
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,15 @@ | |
// limitations under the License. | ||
// | ||
|
||
@import "@material/list/mixins"; | ||
@import "../common"; | ||
@import "../../packages/mdc-drawer/mdc-drawer"; | ||
@import "../../packages/mdc-drawer/mixins"; | ||
@import "../../packages/mdc-elevation/mdc-elevation"; | ||
@import "../../packages/mdc-list/mdc-list"; | ||
|
||
.demo-drawer.mdc-drawer { | ||
@include mdc-drawer-fill-color(#3f51b5); | ||
@include mdc-drawer-ink-color(#fff); | ||
@include mdc-list-item-graphic-ink-color(#fff); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably call the So we probably want something like: .demo-drawer--custom {
@include mdc-drawer-fill-color($material-color-teal-900);
@include mdc-drawer-ink-color(#fff);
.demo-drawer-list-item {
@include mdc-list-item-graphic-ink-color(text-icon-on-dark);
@include mdc-list-item-primary-text-ink-color(text-secondary-on-dark);
}
.demo-drawer-list-item.mdc-list-item--selected {
@include mdc-list-item-graphic-ink-color(text-primary-on-dark);
@include mdc-list-item-primary-text-ink-color(text-primary-on-dark);
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah ok - ya initially I had this in the mixin, but then we took it out. After removing I should have just put it in the demo classes. Makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I also do the same changes on I think I should have rename the selector |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png"> | ||
<script src="/assets/drawer/drawer.css.js"></script> | ||
<script src="/assets/switch.css.js"></script> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono"> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> | ||
|
@@ -51,14 +52,18 @@ | |
} | ||
|
||
/* Place drawer above toolbar shadow. */ | ||
.mdc-permanent-drawer { | ||
.mdc-drawer--permanent { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
z-index: 2; | ||
} | ||
|
||
.demo-main { | ||
padding-left: 16px; | ||
} | ||
|
||
.mdc-demo__control { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's rename this to
And our new convention is to prefix CSS class names for demo pages with (I generally tend to just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gotcha makes sense |
||
margin: 16px 0; | ||
} | ||
|
||
.extra-content-wrapper { | ||
padding: 10px; | ||
} | ||
|
@@ -73,11 +78,11 @@ | |
</style> | ||
</head> | ||
<body class="mdc-typography demo-body"> | ||
<nav class="mdc-permanent-drawer"> | ||
<div class="mdc-permanent-drawer__toolbar-spacer"></div> | ||
<nav class="mdc-drawer mdc-drawer--permanent"> | ||
<div class="mdc-drawer__toolbar-spacer"></div> | ||
<div class="mdc-list-group"> | ||
<nav class="mdc-list"> | ||
<a class="mdc-list-item mdc-permanent-drawer--selected" href="#"> | ||
<a class="mdc-list-item mdc-drawer--selected" href="#"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ditto in other files |
||
<i class="material-icons mdc-list-item__start-detail" aria-hidden="true">inbox</i>Inbox | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
|
@@ -94,17 +99,17 @@ | |
<hr class="mdc-list-divider"> | ||
|
||
<nav class="mdc-list"> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__start-detail" aria-hidden="true">email</i>All Mail | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__start-detail" aria-hidden="true">delete</i>Trash | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__start-detail" aria-hidden="true">report</i>Spam | ||
</a> | ||
</nav> | ||
</div> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__start-detail" aria-hidden="true">email</i>All Mail | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__start-detail" aria-hidden="true">delete</i>Trash | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__start-detail" aria-hidden="true">report</i>Spam | ||
</a> | ||
</nav> | ||
</div> | ||
</nav> | ||
<div class="demo-content"> | ||
<!-- TODO: #324 - Should switch to .mdc-toolbar--fixed --> | ||
|
@@ -122,6 +127,17 @@ | |
<main class="demo-main"> | ||
<h1 class="mdc-typography--display1">Permanent Drawer</h1> | ||
<p class="mdc-typography--body1">It sits to the left of this content.</p> | ||
|
||
<div class="mdc-demo__control"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Ditto for other usages There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So wait, this will end up having 2 classes, right? Sorry for my initial confusion in this comment, I didn't realize we were actually adding uses of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so rule of thumb is if a component is followed by a it should be wrapped in mdc-form-field class? So that means it should also appear in temporary and persistent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kfranqueiro Yes, I believe that's right. |
||
<div class="mdc-switch demo-main__control"> | ||
<input type="checkbox" id="basic-switch" class="mdc-switch__native-control" /> | ||
<div class="mdc-switch__background"> | ||
<div class="mdc-switch__knob"></div> | ||
</div> | ||
</div> | ||
<label for="basic-switch" class="mdc-switch-label">Theme off/on</label> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reword label text to "Custom theme off/on" Ditto in other files |
||
</div> | ||
|
||
<div class="extra-content-wrapper"> | ||
<button id="toggle-wide">Toggle extra-wide content</button> | ||
<div id="extra-wide-content" class="mdc-elevation--z2"> </div> | ||
|
@@ -144,6 +160,16 @@ <h1 class="mdc-typography--display1">Permanent Drawer</h1> | |
document.querySelector('#toggle-tall').addEventListener('click', function() { | ||
extraTall.style.display = extraTall.style.display ? '' : 'none'; | ||
}); | ||
|
||
var drawerEl = document.querySelector('.mdc-drawer'); | ||
var switchEl = document.querySelector('.mdc-switch'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use an ID instead of a class name Ditto in other files |
||
switchEl.addEventListener('change', function(e) { | ||
if(e.target.checked) { | ||
drawerEl.classList.add('demo-drawer'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ditto in other files |
||
} else { | ||
drawerEl.classList.remove('demo-drawer'); | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png"> | ||
<script src="/assets/drawer/drawer.css.js"></script> | ||
<script src="/assets/switch.css.js"></script> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono"> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> | ||
|
@@ -52,6 +53,10 @@ | |
padding-left: 16px; | ||
} | ||
|
||
.mdc-demo__control { | ||
margin: 16px 0; | ||
} | ||
|
||
.extra-content-wrapper { | ||
padding: 10px; | ||
} | ||
|
@@ -78,10 +83,10 @@ | |
</header> | ||
|
||
<div class="demo-content mdc-toolbar-fixed-adjust"> | ||
<nav class="mdc-permanent-drawer"> | ||
<nav class="mdc-drawer mdc-drawer--permanent"> | ||
<div class="mdc-list-group"> | ||
<nav class="mdc-list"> | ||
<a class="mdc-list-item mdc-permanent-drawer--selected" href="#"> | ||
<a class="mdc-list-item mdc-drawer--selected" href="#"> | ||
<i class="material-icons mdc-list-item__start-detail" aria-hidden="true">inbox</i>Inbox | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
|
@@ -113,6 +118,18 @@ | |
<main class="demo-main"> | ||
<h1 class="mdc-typography--display1">Permanent Drawer</h1> | ||
<p class="mdc-typography--body1">It sits to the left of this content.</p> | ||
|
||
<div class="mdc-demo__control"> | ||
<div class="mdc-switch demo-main__control"> | ||
<input type="checkbox" id="basic-switch" class="mdc-switch__native-control" /> | ||
<div class="mdc-switch__background"> | ||
<div class="mdc-switch__knob"></div> | ||
</div> | ||
</div> | ||
<label for="basic-switch" class="mdc-switch-label">Theme off/on</label> | ||
</div> | ||
|
||
|
||
<div class="extra-content-wrapper"> | ||
<button id="toggle-wide">Toggle extra-wide content</button> | ||
<div id="extra-wide-content" class="mdc-elevation--z2"> </div> | ||
|
@@ -135,6 +152,16 @@ <h1 class="mdc-typography--display1">Permanent Drawer</h1> | |
document.querySelector('#toggle-tall').addEventListener('click', function() { | ||
extraTall.style.display = extraTall.style.display ? '' : 'none'; | ||
}); | ||
|
||
var drawerEl = document.querySelector('.mdc-drawer'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For future-proofing, I would probably give both these elements an E.g., Ditto for other files |
||
var switchEl = document.querySelector('.mdc-switch'); | ||
switchEl.addEventListener('change', function(e) { | ||
if(e.target.checked) { | ||
drawerEl.classList.add('demo-drawer'); | ||
} else { | ||
drawerEl.classList.remove('demo-drawer'); | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png"> | ||
<script src="/assets/drawer/drawer.css.js"></script> | ||
<script src="/assets/switch.css.js"></script> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono"> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> | ||
|
@@ -52,16 +53,21 @@ | |
|
||
.demo-main { | ||
padding-left: 16px; | ||
padding-bottom: 16px; | ||
} | ||
|
||
.demo-main__control { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ditto for other files |
||
margin-top: 16px; | ||
} | ||
</style> | ||
</head> | ||
<body class="mdc-typography demo-body"> | ||
<aside class="mdc-persistent-drawer"> | ||
<nav class="mdc-persistent-drawer__drawer"> | ||
<div class="mdc-persistent-drawer__toolbar-spacer"></div> | ||
<aside class="mdc-drawer mdc-drawer--persistent demo-drawer"> | ||
<nav class="mdc-drawer__drawer"> | ||
<div class="mdc-drawer__toolbar-spacer"></div> | ||
<div class="mdc-list-group"> | ||
<nav class="mdc-list"> | ||
<a class="mdc-list-item mdc-persistent-drawer--selected" href="#"> | ||
<a class="mdc-list-item mdc-drawer--selected" href="#"> | ||
<i class="material-icons mdc-list-item__start-detail" aria-hidden="true">inbox</i>Inbox | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
|
@@ -107,11 +113,18 @@ | |
<main class="demo-main"> | ||
<h1 class="mdc-typography--display1">Persistent Drawer</h1> | ||
<p class="mdc-typography--body1">Click the menu icon above to open and close the drawer.</p> | ||
<div class="mdc-switch demo-main__control"> | ||
<input type="checkbox" id="basic-switch" class="mdc-switch__native-control" /> | ||
<div class="mdc-switch__background"> | ||
<div class="mdc-switch__knob"></div> | ||
</div> | ||
</div> | ||
<label for="basic-switch" class="mdc-switch-label">Theme off/on</label> | ||
</main> | ||
|
||
<script src="/assets/material-components-web.js"></script> | ||
<script> | ||
var drawerEl = document.querySelector('.mdc-persistent-drawer'); | ||
var drawerEl = document.querySelector('.mdc-drawer'); | ||
var MDCPersistentDrawer = mdc.drawer.MDCPersistentDrawer; | ||
var drawer = new MDCPersistentDrawer(drawerEl); | ||
document.querySelector('.demo-menu').addEventListener('click', function() { | ||
|
@@ -123,6 +136,15 @@ <h1 class="mdc-typography--display1">Persistent Drawer</h1> | |
drawerEl.addEventListener('MDCPersistentDrawer:close', function() { | ||
console.log('Received MDCPersistentDrawer:close'); | ||
}); | ||
|
||
var switchEl = document.querySelector('.mdc-switch'); | ||
switchEl.addEventListener('change', function(e) { | ||
if(e.target.checked) { | ||
drawerEl.classList.add('demo-drawer'); | ||
} else { | ||
drawerEl.classList.remove('demo-drawer'); | ||
} | ||
}); | ||
</script> | ||
</div> | ||
</body> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we decided to drop the
.mdc-foo
selectors on our demo pages, and just use.demo-foo
instead.This follows BEM, and since our CSS is loaded in a predetermined order, the
.demo-foo
selector should get a higher specificity than the baseline selector (.mdc-foo
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup you're totally correct. For some reason I saw something different last night. Removing .mdc-foo