Add possibility to exclude margin in spool icon for overview sites
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
width: 1.5em;
|
||||
height: 2.5em;
|
||||
gap: 2px;
|
||||
margin: 0 0.5em;
|
||||
}
|
||||
|
||||
.spool-icon.vertical {
|
||||
@@ -14,6 +15,10 @@
|
||||
height: 4em;
|
||||
}
|
||||
|
||||
.spool-icon.no-margin {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.spool-icon * {
|
||||
flex: 1 1 0px;
|
||||
border-radius: 2px;
|
||||
|
||||
@@ -3,12 +3,14 @@ import "./spoolIcon.css";
|
||||
interface Props {
|
||||
color: string | { colors: string[]; vertical: boolean };
|
||||
size?: "small" | "large";
|
||||
no_margin? : boolean
|
||||
}
|
||||
|
||||
export default function SpoolIcon(props: Props) {
|
||||
export default function SpoolIcon(props: Readonly<Props>) {
|
||||
let dirClass = "vertical";
|
||||
let cols = [];
|
||||
let size = props.size ? props.size : "small";
|
||||
let no_margin = props.no_margin ? "no-margin" : "";
|
||||
|
||||
if (typeof props.color === "string") {
|
||||
cols = [props.color];
|
||||
@@ -18,7 +20,7 @@ export default function SpoolIcon(props: Props) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={"spool-icon " + dirClass + " " + size}>
|
||||
<div className={"spool-icon " + dirClass + " " + size + " " + no_margin}>
|
||||
{cols.map((col) => (
|
||||
<div
|
||||
key={col}
|
||||
|
||||
@@ -88,7 +88,7 @@ export const FilamentShow: React.FC<IResourceComponentsProps> = () => {
|
||||
<Title level={5}>{t("filament.fields.name")}</Title>
|
||||
<TextField value={record?.name} />
|
||||
<Title level={5}>{t("filament.fields.color_hex")}</Title>
|
||||
{colorObj && <SpoolIcon color={colorObj} size="large" />}
|
||||
{colorObj && <SpoolIcon color={colorObj} size="large" no_margin />}
|
||||
{record?.color_hex && <TextField value={`#${record?.color_hex}`} />}
|
||||
<Title level={5}>{t("filament.fields.material")}</Title>
|
||||
<TextField value={record?.material} />
|
||||
|
||||
@@ -146,7 +146,8 @@ export const SpoolShow: React.FC<IResourceComponentsProps> = () => {
|
||||
<Title level={5}>{t("spool.fields.id")}</Title>
|
||||
<NumberField value={record?.id ?? ""} />
|
||||
<Title level={5}>{t("spool.fields.filament")}</Title>
|
||||
{colorObj && <SpoolIcon color={colorObj} />} <TextField value={record ? filamentURL(record?.filament) : ""} />
|
||||
{colorObj && <SpoolIcon color={colorObj} size="large" no_margin />}
|
||||
<TextField value={record ? filamentURL(record?.filament) : ""} />
|
||||
<Title level={5}>{t("spool.fields.price")}</Title>
|
||||
<NumberField
|
||||
value={record ? spoolPrice(record) : ""}
|
||||
|
||||
Reference in New Issue
Block a user