|
1 | 1 | import React from "react";
|
2 | 2 | import "./css/main.css";
|
3 | 3 | import styled from "styled-components";
|
| 4 | +import { getThemeValue } from "./ThemeProvider"; |
4 | 5 |
|
5 | 6 | export type ButtonProps = React.HTMLAttributes<
|
6 | 7 | HTMLButtonElement | HTMLAnchorElement
|
@@ -58,41 +59,51 @@ export const Button = (props: ButtonProps) => {
|
58 | 59 | }};
|
59 | 60 | border: ${(props) => {
|
60 | 61 | if (variant !== "outlined") return "none";
|
61 |
| - return `1px solid ${props.theme[accent || "info"]}`; |
| 62 | + return `1px solid ${ |
| 63 | + props.theme[accent || "info"] ?? getThemeValue(accent || "info") |
| 64 | + }`; |
62 | 65 | }};
|
63 | 66 | background-color: ${(props) => {
|
64 |
| - if (variant === "contained") return props.theme[accent || "info"]; |
| 67 | + if (variant === "contained") |
| 68 | + return props.theme[accent || "info"] ?? getThemeValue(accent || "info"); |
65 | 69 | return "transparent";
|
66 | 70 | }};
|
67 | 71 | color: ${(props) => {
|
68 | 72 | if (variant === "contained") return "#fff";
|
69 |
| - return props.theme[accent || "info"]; |
| 73 | + return props.theme[accent || "info"] ?? getThemeValue(accent || "info"); |
70 | 74 | }};
|
71 | 75 |
|
72 | 76 | &:disabled {
|
73 | 77 | border: ${(props) => {
|
74 | 78 | if (variant !== "outlined") return "none";
|
75 |
| - return `1px solid ${props.theme.disabled}`; |
| 79 | + return `1px solid ${props.theme.disabled ?? getThemeValue("disabled")}`; |
76 | 80 | }};
|
77 | 81 | background-color: ${(props) => {
|
78 |
| - if (variant === "contained") return props.theme.disabled; |
| 82 | + if (variant === "contained") |
| 83 | + return props.theme.disabled ?? getThemeValue("disabled"); |
79 | 84 | return "transparent";
|
80 | 85 | }};
|
81 | 86 | color: ${(props) => {
|
82 | 87 | if (variant === "contained") return "#fff";
|
83 |
| - return props.theme.disabled; |
| 88 | + return props.theme.disabled ?? getThemeValue("disabled"); |
84 | 89 | }};
|
85 | 90 | }
|
86 | 91 |
|
87 | 92 | &:hover:not(:disabled) {
|
88 | 93 | filter: drop-shadow(
|
89 |
| - 0em 0.125em 0.625em ${(props) => props.theme[accent || "info"]}80 |
| 94 | + 0em 0.125em 0.625em |
| 95 | + ${(props) => |
| 96 | + props.theme[accent || "info"] ?? |
| 97 | + getThemeValue(accent || "info")}80 |
90 | 98 | )
|
91 | 99 | brightness(110%);
|
92 | 100 | }
|
93 | 101 | &:active:not(:disabled) {
|
94 | 102 | filter: drop-shadow(
|
95 |
| - 0em 0.0625em 0.3125em ${(props) => props.theme[accent || "info"]}80 |
| 103 | + 0em 0.0625em 0.3125em |
| 104 | + ${(props) => |
| 105 | + props.theme[accent || "info"] ?? |
| 106 | + getThemeValue(accent || "info")}80 |
96 | 107 | )
|
97 | 108 | brightness(80%);
|
98 | 109 | }
|
|
0 commit comments