-
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 16 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,24 @@ | |
// limitations under the License. | ||
// | ||
|
||
@import "@material/list/mixins"; | ||
@import "@material/form-field/mdc-form-field"; | ||
@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 { | ||
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 The HTML elements should initially just have Does that make 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. Initially it seemed strange to have a class with no styles on it though, but yup that makes sense as it is more BEM like. |
||
@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 |
||
} | ||
|
||
.demo-form-field { | ||
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 this class name in the HTML |
||
margin: 16px 0; | ||
} | ||
|
||
.demo-switch { | ||
margin-top: 16px; | ||
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. This looks weird - can we remove it? 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 forgot to remove. good catch |
||
} |
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,7 +52,7 @@ | |
} | ||
|
||
/* 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; | ||
} | ||
|
||
|
@@ -73,11 +74,11 @@ | |
</style> | ||
</head> | ||
<body class="mdc-typography demo-body"> | ||
<nav class="mdc-permanent-drawer"> | ||
<div class="mdc-permanent-drawer__toolbar-spacer"></div> | ||
<nav id="demo-theme-switch" 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__graphic" aria-hidden="true">inbox</i>Inbox | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
|
@@ -94,17 +95,17 @@ | |
<hr class="mdc-list-divider"> | ||
|
||
<nav class="mdc-list"> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">email</i>All Mail | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">delete</i>Trash | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">report</i>Spam | ||
</a> | ||
</nav> | ||
</div> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">email</i>All Mail | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">delete</i>Trash | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
<i class="material-icons mdc-list-item__graphic" aria-hidden="true">report</i>Spam | ||
</a> | ||
</nav> | ||
</div> | ||
</nav> | ||
<div class="demo-content"> | ||
<!-- TODO: #324 - Should switch to .mdc-toolbar--fixed --> | ||
|
@@ -122,6 +123,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-form-field demo-form-field"> | ||
<div class="mdc-switch demo-switch"> | ||
<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 +156,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('#demo-theme-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. This should probably be Ditto in other files 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. don't know what I was thinking there...changing |
||
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"> | ||
|
@@ -78,10 +79,10 @@ | |
</header> | ||
|
||
<div class="demo-content mdc-toolbar-fixed-adjust"> | ||
<nav class="mdc-permanent-drawer"> | ||
<nav id="demo-theme-switch" class="mdc-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. Rename Ditto in other files |
||
<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__graphic" aria-hidden="true">inbox</i>Inbox | ||
</a> | ||
<a class="mdc-list-item" href="#"> | ||
|
@@ -113,6 +114,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-form-field demo-form-field"> | ||
<div class="mdc-switch demo-switch"> | ||
<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 +148,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('#demo-theme-switch'); | ||
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> |
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.
For demo pages, we use relative paths in our Sass
@import
s (demo pages don't need to be distributed via npm).