-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbutton.tsx
More file actions
49 lines (41 loc) · 1.27 KB
/
button.tsx
File metadata and controls
49 lines (41 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { A } from '@solidjs/router';
import { JSX } from 'solid-js';
/// Special types of buttons that need specific callouts
export type ButtonRole = 'primary';
export interface VisualButtonProps {
children: JSX.Element;
role?: ButtonRole;
}
const buttonProps = (props: VisualButtonProps) => {
const roleClasses =
// buttonProps is only called within a reactive scope
// eslint-disable-next-line solid/reactivity
props.role === 'primary'
? 'bg-stackable-blue-light hover-bg-stackable-blue-dark active-stackable-blue-dark border-stackable-blue-dark'
: 'bg-gray-700 hover-bg-gray-600 active-bg-gray-500 border-gray-600';
return {
class: `p-2 text-size-4 c-white rounded border-1 border-solid cursor-pointer decoration-none ${roleClasses}`,
};
};
export interface ButtonProps extends VisualButtonProps {
onClick: () => void;
}
export const Button = (props: ButtonProps) => (
<button
{...buttonProps(props)}
onClick={(event) => {
event.preventDefault();
props.onClick();
}}
>
{props.children}
</button>
);
export interface ButtonLinkProps extends VisualButtonProps {
href: string;
}
export const ButtonLink = (props: ButtonLinkProps) => (
<A {...buttonProps(props)} href={props.href}>
{props.children}
</A>
);