File tree Expand file tree Collapse file tree 4 files changed +102
-19
lines changed
material/src/components/button
routes/docs/material/button Expand file tree Collapse file tree 4 files changed +102
-19
lines changed Original file line number Diff line number Diff line change 1
1
import { component$ , QwikIntrinsicElements , Slot } from '@builder.io/qwik' ;
2
2
import { Button as HeadlessButton } from '@qwik-ui/headless' ;
3
+ import { clsq } from '@qwik-ui/shared' ;
3
4
4
- export type ButtonProps = QwikIntrinsicElements [ 'button' ] ;
5
-
6
- export const Button = component$ (
7
- ( props : ButtonProps ) => {
8
- return (
9
- < HeadlessButton class = "waves-effect waves-light btn-large" { ...props } >
10
- < Slot />
11
- </ HeadlessButton >
12
- ) ;
13
- }
14
- ) ;
5
+ export type HTMLButtonProps = QwikIntrinsicElements [ 'button' ] ;
6
+
7
+ export type MaterialButtonProps = {
8
+ disabled ?: boolean ;
9
+ floating ?: boolean ;
10
+ flat ?: boolean ;
11
+ size ?: 'small' | 'medium' | 'large' ;
12
+ } ;
13
+
14
+ export type ButtonProps = HTMLButtonProps & MaterialButtonProps ;
15
+
16
+ export const Button = component$ ( ( props : ButtonProps ) => {
17
+ const {
18
+ class : cls ,
19
+ disabled,
20
+ floating,
21
+ flat,
22
+ size = 'medium' ,
23
+ ...rest
24
+ } = props ;
25
+
26
+ return (
27
+ < HeadlessButton
28
+ { ...rest }
29
+ class = { clsq (
30
+ {
31
+ disabled : disabled ,
32
+ 'btn-floating' : floating ,
33
+ 'btn-flat' : flat ,
34
+ // size
35
+ 'btn-small' : size === 'small' ,
36
+ btn : size === 'medium' ,
37
+ 'btn-large' : size === 'large' ,
38
+ } ,
39
+ cls
40
+ ) }
41
+ >
42
+ < Slot />
43
+ </ HeadlessButton >
44
+ ) ;
45
+ } ) ;
Original file line number Diff line number Diff line change 1
1
import { component$ , Slot , useStyles$ } from '@builder.io/qwik' ;
2
2
import material from '../styles/materialize.scss?inline' ;
3
+ import materialIcons from '../styles/material-icons.css?inline' ;
3
4
4
5
export const MaterialProvider = component$ ( ( ) => {
5
6
useStyles$ ( material ) ;
7
+ useStyles$ ( materialIcons ) ;
6
8
return < Slot /> ;
7
9
} ) ;
Original file line number Diff line number Diff line change
1
+ /* fallback */
2
+ @font-face {
3
+ font-family : 'Material Icons' ;
4
+ font-style : normal;
5
+ font-weight : 400 ;
6
+ src : url (https://fonts.gstatic.com/s/materialicons/v139/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) format ('woff2' );
7
+ }
8
+
9
+ .material-icons {
10
+ font-family : 'Material Icons' ;
11
+ font-weight : normal;
12
+ font-style : normal;
13
+ font-size : 24px ;
14
+ line-height : 1 ;
15
+ letter-spacing : normal;
16
+ text-transform : none;
17
+ display : inline-block;
18
+ white-space : nowrap;
19
+ word-wrap : normal;
20
+ direction : ltr;
21
+ -webkit-font-feature-settings : 'liga' ;
22
+ -webkit-font-smoothing : antialiased;
23
+ }
Original file line number Diff line number Diff line change 1
- import { component$ , $ } from '@builder.io/qwik' ;
1
+ import { component$ , $ , useStylesScoped$ } from '@builder.io/qwik' ;
2
2
import { Button } from '@qwik-ui/material' ;
3
3
import { MaterialContext } from '../../../../../src/components/material' ;
4
4
5
-
6
5
export default component$ ( ( ) => {
6
+ useStylesScoped$ ( `
7
+ .panel {
8
+ display: flex;
9
+ gap: 8px;
10
+ flex-wrap: wrap;
11
+ }` ) ;
12
+
7
13
return (
8
14
< >
9
15
< h2 > This is the documentation for the Button</ h2 >
16
+
10
17
< div class = "flex flex-col gap-8 mt-4" >
11
- < div >
12
- < h2 > Basic Example</ h2 >
13
- < MaterialContext >
14
- < Button onClick$ = { $ ( ( ) => alert ( 'Material' ) ) } > SIMPLE BUTTON</ Button >
15
- </ MaterialContext >
16
- </ div >
18
+ < h2 > Raised</ h2 >
19
+ < MaterialContext >
20
+ < Button > Raised</ Button >
21
+ </ MaterialContext >
22
+ < h2 > Disabled</ h2 >
23
+ < MaterialContext >
24
+ < Button disabled > Disabled</ Button >
25
+ </ MaterialContext >
26
+ < h2 > Floating</ h2 >
27
+ < MaterialContext >
28
+ < Button floating size = 'large' >
29
+ < i class = "material-icons" > add</ i >
30
+ </ Button >
31
+ </ MaterialContext >
32
+ < h2 > Flat</ h2 >
33
+ < MaterialContext >
34
+ < Button flat > Flat</ Button >
35
+ </ MaterialContext >
36
+ < h2 > Size: default medium</ h2 >
37
+ < MaterialContext >
38
+ < div class = "panel" >
39
+ < Button size = { 'small' } > Small</ Button >
40
+ < Button size = { 'medium' } > Medium</ Button >
41
+ < Button size = { 'large' } > Large</ Button >
42
+ </ div >
43
+ </ MaterialContext >
17
44
</ div >
18
45
</ >
19
46
) ;
You can’t perform that action at this time.
0 commit comments