Skip to content

Commit d63f595

Browse files
author
Justin Wilkerson
authored
Merge pull request #3 from weltraumpirat/master
Bugfixes: Allow base props "className" and "style" to work on all components, fix some event listener issues.
2 parents a44f3d0 + 245c0ad commit d63f595

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+427
-227
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
node_modules
44
.cache
55
dist
6-
storybook-static
6+
storybook-static
7+
jest.config.js

src/WiredButton.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export interface WiredButtonProps extends BaseProps {
2626
}
2727

2828
export const WiredButton = ({
29+
className,
30+
style,
2931
onClick,
3032
elevation = 1,
3133
disabled = false,
@@ -34,10 +36,18 @@ export const WiredButton = ({
3436
const customValues = useMemo(() => {
3537
return {
3638
attributes: { disabled, elevation },
37-
methods: { click: onClick },
3839
};
39-
}, [elevation, disabled, onClick]);
40+
}, [elevation, disabled]);
4041

4142
const register = useCustomElement(customValues);
42-
return <wired-button ref={register}>{children}</wired-button>;
43+
return (
44+
<wired-button
45+
onClick={onClick}
46+
class={className}
47+
style={style}
48+
ref={register}
49+
>
50+
{children}
51+
</wired-button>
52+
);
4353
};

src/WiredCalendar.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ export const WiredCalendar = ({
7878
selectedColor = 'red',
7979
dimmedColor = 'gray',
8080
onSelect,
81+
className,
82+
style,
8183
}: WiredCalendarProps) => {
8284
const customValues = useMemo(() => {
8385
return {
@@ -118,7 +120,13 @@ export const WiredCalendar = ({
118120
]);
119121

120122
const register = useCustomElement(customValues);
121-
return <wired-calendar ref={register}></wired-calendar>;
123+
return (
124+
<wired-calendar
125+
class={className}
126+
style={style}
127+
ref={register}
128+
></wired-calendar>
129+
);
122130
};
123131

124132
/*

src/WiredCard.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export const WiredCard = ({
2929
elevation,
3030
fill,
3131
children,
32+
className,
33+
style,
3234
}: WiredCardProps) => {
3335
const customValues = useMemo(() => {
3436
return {
@@ -39,5 +41,9 @@ export const WiredCard = ({
3941

4042
const register = useCustomElement(customValues);
4143

42-
return <wired-card ref={register}>{children}</wired-card>;
44+
return (
45+
<wired-card class={className} style={style} ref={register}>
46+
{children}
47+
</wired-card>
48+
);
4349
};

src/WiredCheckBox.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export const WiredCheckBox = ({
3030
color = 'currentColor',
3131
disabled = false,
3232
onChange,
33+
className,
34+
style,
3335
}: WiredCheckBoxProps) => {
3436
const customValues = useMemo(() => {
3537
return {
@@ -41,5 +43,5 @@ export const WiredCheckBox = ({
4143

4244
const register = useCustomElement(customValues);
4345

44-
return <wired-checkbox ref={register} />;
46+
return <wired-checkbox class={className} style={style} ref={register} />;
4547
};

src/WiredCombo.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export const WiredCombo = ({
4242
onSelect,
4343
popupBgColor = 'white',
4444
selectedBgColor = 'gray',
45+
className,
46+
style,
4547
}: WiredComboProps) => {
4648
const customValues = useMemo(() => {
4749
return {
@@ -55,5 +57,9 @@ export const WiredCombo = ({
5557
}, [disabled, value, onSelect, popupBgColor, selectedBgColor]);
5658

5759
const register = useCustomElement(customValues);
58-
return <wired-combo ref={register}>{children}</wired-combo>;
60+
return (
61+
<wired-combo class={className} style={style} ref={register}>
62+
{children}
63+
</wired-combo>
64+
);
5965
};

src/WiredDialog.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export const WiredDialog = ({
3030
elevation = 1,
3131
open = false,
3232
zIndex = 1,
33+
className,
34+
style,
3335
}: WiredDialogProps) => {
3436
const customValues = useMemo(() => {
3537
return {
@@ -39,5 +41,9 @@ export const WiredDialog = ({
3941
}, [elevation, open, zIndex]);
4042

4143
const register = useCustomElement(customValues);
42-
return <wired-dialog ref={register}>{children}</wired-dialog>;
44+
return (
45+
<wired-dialog class={className} style={style} ref={register}>
46+
{children}
47+
</wired-dialog>
48+
);
4349
};

src/WiredDivider.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ export interface WiredDividerProps extends BaseProps {
1111
elevation?: 1 | 2 | 3 | 4 | 5;
1212
}
1313

14-
export const WiredDivider = ({ elevation = 1 }: WiredDividerProps) => {
14+
export const WiredDivider = ({
15+
elevation = 1,
16+
className,
17+
style,
18+
}: WiredDividerProps) => {
1519
const customValues = useMemo(() => {
1620
return {
1721
attributes: { elevation },
@@ -20,5 +24,11 @@ export const WiredDivider = ({ elevation = 1 }: WiredDividerProps) => {
2024

2125
const register = useCustomElement(customValues);
2226

23-
return <wired-divider ref={register}></wired-divider>;
27+
return (
28+
<wired-divider
29+
class={className}
30+
style={style}
31+
ref={register}
32+
></wired-divider>
33+
);
2434
};

src/WiredFab.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export const WiredFab = ({
4242
icon = 'favorite',
4343
onClick,
4444
children,
45+
className,
46+
style,
4547
}: WiredFabProps) => {
4648
const customValues = useMemo(() => {
4749
return {
@@ -53,7 +55,7 @@ export const WiredFab = ({
5355

5456
const register = useCustomElement(customValues);
5557
return (
56-
<wired-fab ref={register}>
58+
<wired-fab class={className} style={style} ref={register}>
5759
<span>
5860
{children || (
5961
<span className="material-icons" style={{ color: iconColor }}>

src/WiredIconButton.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import { BaseProps } from './types';
33
import { useCustomElement } from './utils/useCustomElement';
44
import { Icon } from './utils/icons';
5+
56
const { useMemo } = React;
67

78
export interface WiredIconButtonProps extends BaseProps {
@@ -30,10 +31,12 @@ export interface WiredIconButtonProps extends BaseProps {
3031
* @default favorite
3132
*/
3233
icon?: Icon;
34+
3335
/**
3436
* Event fired when button is clicked/submitted
3537
*/
3638
onClick?(e: MouseEvent): void;
39+
3740
/**
3841
* The children. Optionally pass in your own icon.
3942
*/
@@ -48,18 +51,24 @@ export const WiredIconButton = ({
4851
iconSize = 24,
4952
onClick,
5053
children,
54+
className,
55+
style,
5156
}: WiredIconButtonProps) => {
5257
const customValues = useMemo(() => {
5358
return {
5459
attributes: { disabled },
55-
methods: { click: onClick },
5660
css: { color: lineColor, '--mdc-icon-size': iconSize },
5761
};
58-
}, [disabled, lineColor, iconSize, onClick]);
62+
}, [disabled, lineColor, iconSize]);
5963

6064
const register = useCustomElement(customValues);
6165
return (
62-
<wired-icon-button ref={register}>
66+
<wired-icon-button
67+
onClick={onClick}
68+
class={className}
69+
style={style}
70+
ref={register}
71+
>
6372
<div style={{ height: '24px', width: '24px' }}>
6473
{children || (
6574
<span

0 commit comments

Comments
 (0)