Refactoring to a base label and extended labels
This commit is contained in:
1 parent
6bd8fec119
commit
f8828fe6e8
5 files changed
+17
-7
No files matched your search
File renamed without changes.
@@ -1,5 +1,5 @@
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import "./index.css";
|
import "./BaseLabel.css";
|
||||||
import { useTheme } from "@mui/material";
|
import { useTheme } from "@mui/material";
|
||||||
|
|
||||||
// Produces a lighter color based on a hex color and a percent
|
// Produces a lighter color based on a hex color and a percent
|
||||||
@@ -43,7 +43,11 @@ const Label = ({ label, color }) => {
|
|||||||
// Calculate lighter shades for border and bg
|
// Calculate lighter shades for border and bg
|
||||||
const borderColor = lightenColor(color, 20);
|
const borderColor = lightenColor(color, 20);
|
||||||
const bgColor = lightenColor(color, 75);
|
const bgColor = lightenColor(color, 75);
|
||||||
|
// Grab the default borderRadius from the theme to match button style
|
||||||
const { borderRadius } = theme.shape;
|
const { borderRadius } = theme.shape;
|
||||||
|
// Calculate padding for the label to mimic button. Appears to scale correctly, not 100% sure though.
|
||||||
|
const padding = theme.spacing(1 * 0.75, 2);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="label"
|
className="label"
|
||||||
@@ -52,7 +56,7 @@ const Label = ({ label, color }) => {
|
|||||||
borderColor: borderColor,
|
borderColor: borderColor,
|
||||||
backgroundColor: bgColor,
|
backgroundColor: bgColor,
|
||||||
color: color,
|
color: color,
|
||||||
padding: theme.spacing(1 * 0.75, 2),
|
padding: padding,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
Whitespace-only changes.
Whitespace-only changes.
@@ -1,7 +1,7 @@
|
|||||||
import DropdownTeamMember from "../../Components/DropdownTeamMember";
|
import DropdownTeamMember from "../../Components/DropdownTeamMember";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import Button from "../../Components/Button";
|
import Button from "../../Components/Button";
|
||||||
import Label from "../../Components/Label";
|
import BaseLabel from "../../Components/Label/BaseLabel";
|
||||||
import { useTheme } from "@mui/material";
|
import { useTheme } from "@mui/material";
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
@@ -27,10 +27,16 @@ const Home = () => {
|
|||||||
</div>
|
</div>
|
||||||
<h4>Labels</h4>
|
<h4>Labels</h4>
|
||||||
<div>
|
<div>
|
||||||
<Label label="Label" color={theme.palette.labelOrange.textColor} />
|
<BaseLabel label="Label" color={theme.palette.labelGray.textColor} />
|
||||||
<Label label="Label" color={theme.palette.labelGray.textColor} />
|
<BaseLabel
|
||||||
<Label label="Label" color={theme.palette.labelPurple.textColor} />
|
label="Label"
|
||||||
<Label label="Label" color={theme.palette.labelGreen.textColor} />
|
color={theme.palette.labelPurple.textColor}
|
||||||
|
/>
|
||||||
|
<BaseLabel label="Label" color={theme.palette.labelGreen.textColor} />
|
||||||
|
<BaseLabel
|
||||||
|
label="Label"
|
||||||
|
color={theme.palette.labelOrange.textColor}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in new issue
Block a user