Skip to content

Commit

Permalink
[console] - adjusted setpoint styling
Browse files Browse the repository at this point in the history
  • Loading branch information
emilbon99 committed Sep 26, 2024
1 parent 895ea2e commit 0062755
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 30 deletions.
2 changes: 1 addition & 1 deletion console/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import "@/index.css";
import "@synnaxlabs/media/dist/style.css";
import "@synnaxlabs/pluto/dist/style.css";

// import "@synnaxlabs/pluto/dist/style.css";
import { Provider } from "@synnaxlabs/drift/react";
import { type Haul, Pluto, type state, type Triggers } from "@synnaxlabs/pluto";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
Expand Down
15 changes: 15 additions & 0 deletions pluto/src/button/Button.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@
background: var(--pluto-bg);
border: var(--pluto-border-width) solid var(--pluto-gray-l4);

&.pluto-btn--custom-color {
--pluto-bg: rgba(var(--pluto-btn-color), 1);
border-color: var(--pluto-bg) !important;

&:hover:not(.pluto--disabled) {
--pluto-bg: rgba(var(--pluto-btn-color), 0.75);
border-color: var(--pluto-bg) !important;
}

&:active:not(.pluto--disabled) {
--pluto-bg: rgba(var(--pluto-btn-color), 1);
border-color: var(--pluto-bg) !important;
}
}

&.pluto--warning {
border-color: var(--pluto-warning-z) !important;
color: var(--pluto-warning-z);
Expand Down
5 changes: 2 additions & 3 deletions pluto/src/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ export const Button = Tooltip.wrap(

const pStyle = { ...style };
const res = Color.Color.z.safeParse(color);
const hasCustomColor = res.success && variant === "filled";
const hasCustomColor =
res.success && (variant === "filled" || variant === "outlined");
if (hasCustomColor) {
// @ts-expect-error - css variable
pStyle[CSS.var("btn-color")] = res.data.rgbString;
Expand All @@ -146,8 +147,6 @@ export const Button = Tooltip.wrap(
else if (size != null && level == null) level = Text.ComponentSizeLevels[size];
else if (size == null) size = "medium";

console.log(className, endContent, endContent != null);

return (
<Text.WithIcon<"button", any>
el="button"
Expand Down
2 changes: 1 addition & 1 deletion pluto/src/input/Input.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}

& > .pluto-input__internal:focus-within {
border-color: var(--pluto-primary-z) !important;
border-color: var(--pluto-input-color, var(--pluto-primary-z)) !important;
& input {
outline: none;
}
Expand Down
4 changes: 2 additions & 2 deletions pluto/src/input/Numeric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { type BaseProps } from "@/input/types";
import { Triggers } from "@/triggers";

export interface NumericProps
extends Omit<BaseProps<number>, "type" | "onBlur">,
extends Omit<BaseProps<number>, "type" | "onBlur" | "color">,
DragButtonExtraProps,
TextExtraProps {
selectOnFocus?: boolean;
Expand All @@ -38,7 +38,7 @@ export interface NumericProps
* @param props.size - The size of the input: "small" | "medium" | "large".
* @default "medium"
* @param props.selectOnFocus - Whether the input should select its contents when focused.
* @defaul true
* @default true
* @param props.centerPlaceholder - Whether the placeholder should be centered.
* @default false
* @param props.showDragHandle - Whether or not to show a drag handle to set the time.
Expand Down
8 changes: 6 additions & 2 deletions pluto/src/input/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import "@/input/Input.css";
import { forwardRef, useRef, useState } from "react";

import { Align } from "@/align";
import { Color } from "@/color";
import { CSS } from "@/css";
import { useCombinedRefs } from "@/hooks";
import { type BaseProps } from "@/input/types";
Expand All @@ -24,9 +25,10 @@ export interface TextExtraProps {
resetOnBlurIfEmpty?: boolean;
status?: Status.Variant;
onlyChangeOnBlur?: boolean;
color?: Color.Crude;
}

export interface TextProps extends BaseProps<string>, TextExtraProps {}
export interface TextProps extends Omit<BaseProps<string>, "color">, TextExtraProps {}

/**
* A controlled string input component.
Expand Down Expand Up @@ -114,6 +116,8 @@ export const Text = forwardRef<HTMLInputElement, TextProps>(

const disabledCSS = disabled && CSS.BM("input", "disabled");
if (variant === "preview") disabled = true;
if (color != null)
style = { ...style, [CSS.var("input-color")]: Color.cssString(color) };

const showPlaceholder = (value == null || value.length === 0) && tempValue == null;

Expand Down Expand Up @@ -171,7 +175,7 @@ export const Text = forwardRef<HTMLInputElement, TextProps>(
className={CSS(CSS.visible(false), level != null && CSS.BM("text", level))}
disabled={disabled}
placeholder={typeof placeholder === "string" ? placeholder : undefined}
style={{ fontWeight: weight, color }}
style={{ fontWeight: weight }}
{...props}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion pluto/src/vis/diagram/Diagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const Core = Aether.wrap<DiagramProps>(
const resizeRef = Canvas.useRegion(
useCallback(
(b) => {
debouncedFitView({ maxZoom: 1 });
if (fitViewOnResize) debouncedFitView({ maxZoom: 1 });
setState((prev) => ({ ...prev, region: b }));
},
[setState, debouncedFitView, fitViewOnResize],
Expand Down
24 changes: 10 additions & 14 deletions pluto/src/vis/schematic/Forms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const OrientationControl = ({
);

const LabelControls = ({ path }: { path: string }): ReactElement => (
<Align.Space direction="x" align="stretch">
<Align.Space direction="x" align="stretch" grow>
<Form.Field<string> path={path + ".label"} label="Label" padHelpText={false} grow>
{(p) => <Input.Text selectOnFocus {...p} />}
</Form.Field>
Expand Down Expand Up @@ -750,19 +750,15 @@ export const SetpointForm = (): ReactElement => {
default:
return (
<FormWrapper direction="x" align="stretch">
<Align.Space direction="y" grow>
<Align.Space direction="x" align="stretch">
<LabelControls path="label" />
<Form.Field<string>
path="units"
label="Units"
align="start"
padHelpText={false}
>
{(p) => <Input.Text {...p} />}
</Form.Field>
<ColorControl path="color" />
</Align.Space>
<Align.Space direction="x" align="stretch" grow>
<LabelControls path="label" />
<Form.TextField
path="units"
label="Units"
align="start"
padHelpText={false}
/>
<ColorControl path="color" />
</Align.Space>
<OrientationControl path="" />
</FormWrapper>
Expand Down
3 changes: 0 additions & 3 deletions pluto/src/vis/schematic/primitives/Primitives.css
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@
.pluto-btn {
background: var(--pluto-gray-l2) !important;
}
.pluto-input__internal:not(:active):not(:focus-within) {
border-right: none !important;
}
.pluto-units {
padding: 0 1rem;
}
Expand Down
3 changes: 2 additions & 1 deletion pluto/src/vis/schematic/primitives/Primitives.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1217,13 +1217,14 @@ export const Setpoint = ({
showDragHandle={false}
selectOnFocus
endContent={units}
color={color}
style={{ [CSS.var("pack-border-shade")]: Color.cssString(color) }}
>
<CoreButton.Button
variant="outlined"
size="small"
onClick={() => onChange(currValue)}
color={Color.cssString(color)}
color={color}
>
Set
</CoreButton.Button>
Expand Down
4 changes: 2 additions & 2 deletions pluto/src/vis/schematic/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ const setpoint: Spec<SetpointProps> = {
Form: SetpointForm,
defaultProps: (t) => ({
units: "mV",
color: t.colors.gray.l9.rgba255,
color: t.colors.gray.l4.rgba255,
...zeroLabel("Setpoint"),
...ZERO_NUMERIC_SOURCE_PROPS,
...ZERO_NUMERIC_SINK_PROPS,
Expand Down Expand Up @@ -824,7 +824,7 @@ const textBox: Spec<TextBoxProps> = {
width: 75,
}),
Preview: TextBoxPreview,
zIndex: Z_INDEX_LOWER,
zIndex: Z_INDEX_UPPER,
};

const offPageReference: Spec<ArrowProps> = {
Expand Down

0 comments on commit 0062755

Please sign in to comment.