-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(button): add button component & demos
- Loading branch information
Showing
8 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Button · Material-Me Component Demo</title> | ||
<link rel="stylesheet" href="../assets/css/index.css" /> | ||
<style></style> | ||
<script type="module"> | ||
import '../../dist/components/page.js'; | ||
import '../../dist/components/button.js'; | ||
</script> | ||
</head> | ||
<body> | ||
<mm-page id="root" theme="auto"> | ||
<main> | ||
<h1>Button</h1> | ||
<section> | ||
<mm-button> Filled button </mm-button> | ||
<mm-button type="elevated"> Elevated button </mm-button> | ||
<mm-button type="filled-tonal"> Tonal button </mm-button> | ||
<mm-button type="outlined"> Outlined button </mm-button> | ||
<mm-button type="text"> Text button </mm-button> | ||
</section> | ||
</main> | ||
</mm-page> | ||
</body> | ||
</html> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './button/button'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
:host { | ||
display: inline-flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
box-sizing: border-box; | ||
position: relative; | ||
background-color: rgb(var(--mm-color-primary)); | ||
color: rgb(var(--mm-color-on-primary)); | ||
font-size: 0.875rem; | ||
text-transform: capitalize; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
border-radius: 20px; | ||
padding: 10px 24px; | ||
min-height: 40px; | ||
cursor: pointer; | ||
-webkit-user-select: none; | ||
user-select: none; | ||
--mm-ripple-color: currentColor; | ||
transition: all 0.12s; | ||
} | ||
:host([type='elevated']) { | ||
box-shadow: var(--mm-elevation-level1); | ||
background-color: rgb(var(--mm-color-surface-container-low)); | ||
color: rgb(var(--mm-color-primary)); | ||
} | ||
:host([type='elevated']:hover) { | ||
box-shadow: var(--mm-elevation-level2); | ||
} | ||
:host([type='filled-tonal']) { | ||
background-color: rgb(var(--mm-color-secondary-container)); | ||
color: rgb(var(--mm-color-on-secondary-container)); | ||
} | ||
:host([type='filled-tonal']:hover) { | ||
box-shadow: var(--mm-elevation-level1); | ||
} | ||
:host([type='outlined']) { | ||
color: rgb(var(--mm-color-primary)); | ||
background-color: initial; | ||
border: solid 1px rgb(var(--mm-color-outline)); | ||
} | ||
:host([type='text']) { | ||
color: rgb(var(--mm-color-primary)); | ||
background-color: initial; | ||
padding: 10px 14px; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<slot></slot> | ||
<mm-ripple attached></mm-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useElement } from '../../core/element'; | ||
import '../ripple'; | ||
import template from './button.html'; | ||
import style from './button.css'; | ||
|
||
const name = 'mm-button'; | ||
const props = { | ||
type: 'filled' as | ||
| 'elevated' | ||
| 'filled' | ||
| 'filled-tonal' | ||
| 'outlined' | ||
| 'text', | ||
}; | ||
|
||
export class Button extends useElement({ | ||
template, | ||
style, | ||
props, | ||
syncProps: ['type'], | ||
}) {} | ||
|
||
Button.define(name); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './button'; | ||
export * from './page'; | ||
export * from './ripple'; |