Last active
October 12, 2019 15:48
-
-
Save dbollinger/12f917a7d24ffceabaa23cc8a17065ca to your computer and use it in GitHub Desktop.
ember modifier for material design ripple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$primary: blue; | |
$secondary: yellow; // 👹 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functionalModifier from 'ember-functional-modifiers'; | |
import { MDCRipple } from '@material/ripple/index'; | |
export function mdcRipple(element, params/* hash */) { | |
let color = params[0] || 'primary'; | |
element.classList.add('mdc-ripple-surface'); | |
element.classList.add(`mdc-ripple-surface--${color}`); | |
element.ripple = new MDCRipple(element); | |
} | |
export default functionalModifier(mdcRipple); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import 'app-theme'; | |
// everything below this is copied from build output of building sass from @material project | |
// because I couldn't figure out how to integrate with ember-cli-sass when I made this | |
@keyframes mdc-ripple-fg-radius-in { | |
from { | |
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); | |
transform: translate(var(--mdc-ripple-fg-translate-start, 0)) scale(1); | |
} | |
to { | |
transform: translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1)); | |
} | |
} | |
@keyframes mdc-ripple-fg-opacity-in { | |
from { | |
animation-timing-function: linear; | |
opacity: 0; | |
} | |
to { | |
opacity: var(--mdc-ripple-fg-opacity, 0); | |
} | |
} | |
@keyframes mdc-ripple-fg-opacity-out { | |
from { | |
animation-timing-function: linear; | |
opacity: var(--mdc-ripple-fg-opacity, 0); | |
} | |
to { | |
opacity: 0; | |
} | |
} | |
.mdc-ripple-surface--test-edge-var-bug { | |
--mdc-ripple-surface-test-edge-var: 1px solid #000; | |
visibility: hidden; | |
} | |
.mdc-ripple-surface--test-edge-var-bug::before { | |
border: var(--mdc-ripple-surface-test-edge-var); | |
} | |
.mdc-ripple-surface { | |
--mdc-ripple-fg-size: 0; | |
--mdc-ripple-left: 0; | |
--mdc-ripple-top: 0; | |
--mdc-ripple-fg-scale: 1; | |
--mdc-ripple-fg-translate-end: 0; | |
--mdc-ripple-fg-translate-start: 0; | |
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); | |
will-change: transform, opacity; | |
position: relative; | |
outline: none; | |
overflow: hidden; | |
} | |
.mdc-ripple-surface::before, .mdc-ripple-surface::after { | |
position: absolute; | |
border-radius: 50%; | |
opacity: 0; | |
pointer-events: none; | |
content: ""; | |
} | |
.mdc-ripple-surface::before { | |
transition: opacity 15ms linear, background-color 15ms linear; | |
z-index: 1; | |
} | |
.mdc-ripple-surface.mdc-ripple-upgraded::before { | |
transform: scale(var(--mdc-ripple-fg-scale, 1)); | |
} | |
.mdc-ripple-surface.mdc-ripple-upgraded::after { | |
top: 0; | |
/* @noflip */ | |
left: 0; | |
transform: scale(0); | |
transform-origin: center center; | |
} | |
.mdc-ripple-surface.mdc-ripple-upgraded--unbounded::after { | |
top: var(--mdc-ripple-top, 0); | |
/* @noflip */ | |
left: var(--mdc-ripple-left, 0); | |
} | |
.mdc-ripple-surface.mdc-ripple-upgraded--foreground-activation::after { | |
animation: mdc-ripple-fg-radius-in 225ms forwards, mdc-ripple-fg-opacity-in 75ms forwards; | |
} | |
.mdc-ripple-surface.mdc-ripple-upgraded--foreground-deactivation::after { | |
animation: mdc-ripple-fg-opacity-out 150ms; | |
transform: translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1)); | |
} | |
.mdc-ripple-surface::before, .mdc-ripple-surface::after { | |
background-color: #000; | |
} | |
.mdc-ripple-surface:hover::before { | |
opacity: 0.04; | |
} | |
.mdc-ripple-surface:not(.mdc-ripple-upgraded):focus::before, .mdc-ripple-surface.mdc-ripple-upgraded--background-focused::before { | |
transition-duration: 75ms; | |
opacity: 0.12; | |
} | |
.mdc-ripple-surface:not(.mdc-ripple-upgraded)::after { | |
transition: opacity 150ms linear; | |
} | |
.mdc-ripple-surface:not(.mdc-ripple-upgraded):active::after { | |
transition-duration: 75ms; | |
opacity: 0.12; | |
} | |
.mdc-ripple-surface.mdc-ripple-upgraded { | |
--mdc-ripple-fg-opacity: 0.12; | |
} | |
.mdc-ripple-surface::before, .mdc-ripple-surface::after { | |
top: calc(50% - 100%); | |
/* @noflip */ | |
left: calc(50% - 100%); | |
width: 200%; | |
height: 200%; | |
} | |
.mdc-ripple-surface.mdc-ripple-upgraded::after { | |
width: var(--mdc-ripple-fg-size, 100%); | |
height: var(--mdc-ripple-fg-size, 100%); | |
} | |
.mdc-ripple-surface[data-mdc-ripple-is-unbounded] { | |
overflow: visible; | |
} | |
.mdc-ripple-surface[data-mdc-ripple-is-unbounded]::before, .mdc-ripple-surface[data-mdc-ripple-is-unbounded]::after { | |
top: calc(50% - 50%); | |
/* @noflip */ | |
left: calc(50% - 50%); | |
width: 100%; | |
height: 100%; | |
} | |
.mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::before, .mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::after { | |
top: var(--mdc-ripple-top, calc(50% - 50%)); | |
/* @noflip */ | |
left: var(--mdc-ripple-left, calc(50% - 50%)); | |
width: var(--mdc-ripple-fg-size, 100%); | |
height: var(--mdc-ripple-fg-size, 100%); | |
} | |
.mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::after { | |
width: var(--mdc-ripple-fg-size, 100%); | |
height: var(--mdc-ripple-fg-size, 100%); | |
} | |
.mdc-ripple-surface--primary::before, .mdc-ripple-surface--primary::after { | |
background-color: #6200ee; | |
} | |
@supports not (-ms-ime-align: auto) { | |
.mdc-ripple-surface--primary::before, .mdc-ripple-surface--primary::after { | |
/* @alternate */ | |
background-color: var(--mdc-theme-primary, #6200ee); | |
} | |
} | |
.mdc-ripple-surface--primary:hover::before { | |
opacity: 0.04; | |
} | |
.mdc-ripple-surface--primary:not(.mdc-ripple-upgraded):focus::before, .mdc-ripple-surface--primary.mdc-ripple-upgraded--background-focused::before { | |
transition-duration: 75ms; | |
opacity: 0.12; | |
} | |
.mdc-ripple-surface--primary:not(.mdc-ripple-upgraded)::after { | |
transition: opacity 150ms linear; | |
} | |
.mdc-ripple-surface--primary:not(.mdc-ripple-upgraded):active::after { | |
transition-duration: 75ms; | |
opacity: 0.12; | |
} | |
.mdc-ripple-surface--primary.mdc-ripple-upgraded { | |
--mdc-ripple-fg-opacity: 0.12; | |
} | |
.mdc-ripple-surface--accent::before, .mdc-ripple-surface--accent::after { | |
background-color: #018786; | |
} | |
@supports not (-ms-ime-align: auto) { | |
.mdc-ripple-surface--accent::before, .mdc-ripple-surface--accent::after { | |
/* @alternate */ | |
background-color: var(--mdc-theme-secondary, #018786); | |
} | |
} | |
.mdc-ripple-surface--accent:hover::before { | |
opacity: 0.04; | |
} | |
.mdc-ripple-surface--accent:not(.mdc-ripple-upgraded):focus::before, .mdc-ripple-surface--accent.mdc-ripple-upgraded--background-focused::before { | |
transition-duration: 75ms; | |
opacity: 0.12; | |
} | |
.mdc-ripple-surface--accent:not(.mdc-ripple-upgraded)::after { | |
transition: opacity 150ms linear; | |
} | |
.mdc-ripple-surface--accent:not(.mdc-ripple-upgraded):active::after { | |
transition-duration: 75ms; | |
opacity: 0.12; | |
} | |
.mdc-ripple-surface--accent.mdc-ripple-upgraded { | |
--mdc-ripple-fg-opacity: 0.12; | |
} | |
:root { | |
--mdc-theme-primary: #{$primary}; | |
--mdc-theme-secondary: #{$secondary}; | |
--mdc-theme-background: #fff; | |
--mdc-theme-surface: #fff; | |
--mdc-theme-error: #b00020; | |
--mdc-theme-on-primary: #fff; | |
--mdc-theme-on-secondary: #fff; | |
--mdc-theme-on-surface: #000; | |
--mdc-theme-on-error: #fff; | |
--mdc-theme-text-primary-on-background: rgba(0, 0, 0, 0.87); | |
--mdc-theme-text-secondary-on-background: rgba(0, 0, 0, 0.54); | |
--mdc-theme-text-hint-on-background: rgba(0, 0, 0, 0.38); | |
--mdc-theme-text-disabled-on-background: rgba(0, 0, 0, 0.38); | |
--mdc-theme-text-icon-on-background: rgba(0, 0, 0, 0.38); | |
--mdc-theme-text-primary-on-light: rgba(0, 0, 0, 0.87); | |
--mdc-theme-text-secondary-on-light: rgba(0, 0, 0, 0.54); | |
--mdc-theme-text-hint-on-light: rgba(0, 0, 0, 0.38); | |
--mdc-theme-text-disabled-on-light: rgba(0, 0, 0, 0.38); | |
--mdc-theme-text-icon-on-light: rgba(0, 0, 0, 0.38); | |
--mdc-theme-text-primary-on-dark: white; | |
--mdc-theme-text-secondary-on-dark: rgba(255, 255, 255, 0.7); | |
--mdc-theme-text-hint-on-dark: rgba(255, 255, 255, 0.5); | |
--mdc-theme-text-disabled-on-dark: rgba(255, 255, 255, 0.5); | |
--mdc-theme-text-icon-on-dark: rgba(255, 255, 255, 0.5); | |
} | |
.mdc-theme--primary { | |
color: #6200ee !important; | |
/* @alternate */ | |
color: var(--mdc-theme-primary, #6200ee) !important; | |
} | |
.mdc-theme--secondary { | |
color: #018786 !important; | |
/* @alternate */ | |
color: var(--mdc-theme-secondary, #018786) !important; | |
} | |
.mdc-theme--background { | |
background-color: #fff; | |
/* @alternate */ | |
background-color: var(--mdc-theme-background, #fff); | |
} | |
.mdc-theme--surface { | |
background-color: #fff; | |
/* @alternate */ | |
background-color: var(--mdc-theme-surface, #fff); | |
} | |
.mdc-theme--error { | |
color: #b00020 !important; | |
/* @alternate */ | |
color: var(--mdc-theme-error, #b00020) !important; | |
} | |
.mdc-theme--on-primary { | |
color: #fff !important; | |
/* @alternate */ | |
color: var(--mdc-theme-on-primary, #fff) !important; | |
} | |
.mdc-theme--on-secondary { | |
color: #fff !important; | |
/* @alternate */ | |
color: var(--mdc-theme-on-secondary, #fff) !important; | |
} | |
.mdc-theme--on-surface { | |
color: #000 !important; | |
/* @alternate */ | |
color: var(--mdc-theme-on-surface, #000) !important; | |
} | |
.mdc-theme--on-error { | |
color: #fff !important; | |
/* @alternate */ | |
color: var(--mdc-theme-on-error, #fff) !important; | |
} | |
.mdc-theme--text-primary-on-background { | |
color: rgba(0, 0, 0, 0.87) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87)) !important; | |
} | |
.mdc-theme--text-secondary-on-background { | |
color: rgba(0, 0, 0, 0.54) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-secondary-on-background, rgba(0, 0, 0, 0.54)) !important; | |
} | |
.mdc-theme--text-hint-on-background { | |
color: rgba(0, 0, 0, 0.38) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-hint-on-background, rgba(0, 0, 0, 0.38)) !important; | |
} | |
.mdc-theme--text-disabled-on-background { | |
color: rgba(0, 0, 0, 0.38) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-disabled-on-background, rgba(0, 0, 0, 0.38)) !important; | |
} | |
.mdc-theme--text-icon-on-background { | |
color: rgba(0, 0, 0, 0.38) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-icon-on-background, rgba(0, 0, 0, 0.38)) !important; | |
} | |
.mdc-theme--text-primary-on-light { | |
color: rgba(0, 0, 0, 0.87) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-primary-on-light, rgba(0, 0, 0, 0.87)) !important; | |
} | |
.mdc-theme--text-secondary-on-light { | |
color: rgba(0, 0, 0, 0.54) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-secondary-on-light, rgba(0, 0, 0, 0.54)) !important; | |
} | |
.mdc-theme--text-hint-on-light { | |
color: rgba(0, 0, 0, 0.38) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-hint-on-light, rgba(0, 0, 0, 0.38)) !important; | |
} | |
.mdc-theme--text-disabled-on-light { | |
color: rgba(0, 0, 0, 0.38) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-disabled-on-light, rgba(0, 0, 0, 0.38)) !important; | |
} | |
.mdc-theme--text-icon-on-light { | |
color: rgba(0, 0, 0, 0.38) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-icon-on-light, rgba(0, 0, 0, 0.38)) !important; | |
} | |
.mdc-theme--text-primary-on-dark { | |
color: white !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-primary-on-dark, white) !important; | |
} | |
.mdc-theme--text-secondary-on-dark { | |
color: rgba(255, 255, 255, 0.7) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-secondary-on-dark, rgba(255, 255, 255, 0.7)) !important; | |
} | |
.mdc-theme--text-hint-on-dark { | |
color: rgba(255, 255, 255, 0.5) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-hint-on-dark, rgba(255, 255, 255, 0.5)) !important; | |
} | |
.mdc-theme--text-disabled-on-dark { | |
color: rgba(255, 255, 255, 0.5) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-disabled-on-dark, rgba(255, 255, 255, 0.5)) !important; | |
} | |
.mdc-theme--text-icon-on-dark { | |
color: rgba(255, 255, 255, 0.5) !important; | |
/* @alternate */ | |
color: var(--mdc-theme-text-icon-on-dark, rgba(255, 255, 255, 0.5)) !important; | |
} | |
.mdc-theme--primary-bg { | |
background-color: #6200ee !important; | |
/* @alternate */ | |
background-color: var(--mdc-theme-primary, #6200ee) !important; | |
} | |
.mdc-theme--secondary-bg { | |
background-color: #018786 !important; | |
/* @alternate */ | |
background-color: var(--mdc-theme-secondary, #018786) !important; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@material/ripple: "3.2.0", | |
ember-auto-import: "^1.5.2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment