mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-07 20:44:05 +09:00
wip font picker
This commit is contained in:
1 parent
f17ea9e20b
commit
9cf22ee046
4 files changed
+57
-1
No files matched your search
+47
@@ -0,0 +1,47 @@
|
||||
import { Grid, TextField } from "@webstudio-is/design-system";
|
||||
import type { ControlProps } from "../../style-sections";
|
||||
import { getFinalValue } from "../../shared/get-final-value";
|
||||
import { PropertyName } from "../../shared/property-name";
|
||||
|
||||
const textFieldStyle = {
|
||||
height: "$6",
|
||||
fontWeight: "500",
|
||||
};
|
||||
|
||||
export const FontFamilyControl = ({
|
||||
currentStyle,
|
||||
inheritedStyle,
|
||||
setProperty,
|
||||
styleConfig,
|
||||
}: ControlProps) => {
|
||||
// @todo show which instance we inherited the value from
|
||||
const value = getFinalValue({
|
||||
currentStyle,
|
||||
inheritedStyle,
|
||||
property: styleConfig.property,
|
||||
});
|
||||
|
||||
if (value === undefined) return null;
|
||||
|
||||
const setValue = setProperty(styleConfig.property);
|
||||
|
||||
return (
|
||||
<Grid columns={2}>
|
||||
<PropertyName property={styleConfig.property} label={styleConfig.label} />
|
||||
<TextField
|
||||
css={textFieldStyle}
|
||||
spellCheck={false}
|
||||
readOnly
|
||||
defaultValue={value.value}
|
||||
onClick={() => {
|
||||
console.log("show font picker");
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Enter") {
|
||||
console.log("show font picker");
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
@@ -3,3 +3,4 @@ export * from "./color/color-control";
|
||||
export * from "./select/select-control";
|
||||
export * from "./menu/menu-control";
|
||||
export * from "./spacing/spacing-control";
|
||||
export * from "./font-family/font-family-control";
|
||||
@@ -45,13 +45,15 @@ type BaseStyleConfig = {
|
||||
appliesTo: AppliesTo;
|
||||
};
|
||||
|
||||
// @todo make it use actual list of controls
|
||||
export type Control =
|
||||
| "Spacing"
|
||||
| "Text"
|
||||
| "Color"
|
||||
| "Menu"
|
||||
| "Select"
|
||||
| "Empty";
|
||||
| "Empty"
|
||||
| "FontFamily";
|
||||
|
||||
export type StyleConfig = BaseStyleConfig & {
|
||||
control: Control;
|
||||
@@ -88,6 +90,9 @@ const getControl = (property: StyleProperty): Control => {
|
||||
case "placeContent": {
|
||||
return "Empty";
|
||||
}
|
||||
case "fontFamily": {
|
||||
return "FontFamily";
|
||||
}
|
||||
}
|
||||
|
||||
return "Text";
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
TextControl,
|
||||
SelectControl,
|
||||
MenuControl,
|
||||
FontFamilyControl,
|
||||
} from "./controls";
|
||||
import { ShowMore } from "./shared/show-more";
|
||||
import { LayoutSection } from "./sections";
|
||||
@@ -126,6 +127,7 @@ const sections: {
|
||||
} = {
|
||||
layout: LayoutSection,
|
||||
};
|
||||
|
||||
const controls: {
|
||||
[key: string]: (props: ControlProps) => JSX.Element | null;
|
||||
} = {
|
||||
@@ -134,4 +136,5 @@ const controls: {
|
||||
Color: ColorControl,
|
||||
Select: SelectControl,
|
||||
Spacing: SpacingControl,
|
||||
FontFamily: FontFamilyControl,
|
||||
};
|
||||
Reference in new issue
Block a user