Skip to content

Commit

Permalink
Add ColorInput
Browse files Browse the repository at this point in the history
  • Loading branch information
seanchas116 committed Apr 30, 2023
1 parent 4c1d84c commit 62dc50e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/editor/src/views/inspector/style/TextPane.tsx
Expand Up @@ -19,6 +19,10 @@ import { InspectorTargetContext } from "../components/InspectorTargetContext";
import { projectState } from "../../../state/ProjectState";
import { InspectorComboBox } from "./inputs/InspectorComboBox";
import googleFonts from "@uimix/foundation/src/fonts/GoogleFonts.json";
import { ColorInput } from "../components/ColorInput";
import { sameOrMixed, sameOrNone } from "@uimix/foundation/src/utils/Mixed";
import { ColorRef } from "@uimix/model/src/models";
import { action } from "mobx";

const googleFontOptions = googleFonts.items.map((item) => ({
value: item.family,
Expand Down Expand Up @@ -68,6 +72,9 @@ export const TextPane: React.FC = observer(function TextPane() {
return null;
}

// TODO: Add InspectorColorInput?
const color = sameOrNone(textSelectables.map((s) => s.style.color));

return (
<InspectorPane>
<InspectorHeading
Expand All @@ -76,6 +83,21 @@ export const TextPane: React.FC = observer(function TextPane() {
/>
<InspectorTargetContext.Provider value={textSelectables}>
<div className="flex flex-col gap-2">
<ColorInput
value={
color != null
? ColorRef.fromJSON(projectState.project, color)
: undefined
}
onChange={action((color) => {
for (const selectable of textSelectables) {
selectable.style.color = color?.toJSON() ?? "#000000";
}
})}
onChangeEnd={action(() => {
projectState.undoManager.stopCapturing();
})}
/>
<InspectorComboBox
get={(s) => s.style.fontFamily}
set={(s, value) => {
Expand Down

0 comments on commit 62dc50e

Please sign in to comment.