Skip to content

Commit

Permalink
chore(ui): introduce constant to DRY - WF-127
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Dec 13, 2024
1 parent 14a67b2 commit da30777
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 90 deletions.
23 changes: 5 additions & 18 deletions src/ui/src/builder/settings/BuilderFieldsAlign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ import { useComponentActions } from "../useComponentActions";
import injectionKeys from "@/injectionKeys";
import BuilderSelect from "../BuilderSelect.vue";
import BuilderTemplateInput from "./BuilderTemplateInput.vue";
import WdsTabs, { WdsTabOptions } from "@/wds/WdsTabs.vue";
import WdsTabs from "@/wds/WdsTabs.vue";
import {
BuilderFieldCssMode as Mode,
BUILDER_FIELD_CSS_TAB_OPTIONS as tabs,
} from "./constants/builderFieldsCssTabs";
const wf = inject(injectionKeys.core);
const ssbm = inject(injectionKeys.builderManager);
Expand All @@ -57,23 +61,6 @@ const rootEl: Ref<HTMLElement> = ref(null);
const pickerEl: Ref<HTMLInputElement> = ref(null);
const freehandInputEl: Ref<HTMLInputElement> = ref(null);
type Mode = "pick" | "css" | "default";
const tabs: WdsTabOptions<Mode>[] = [
{
label: "Default",
value: "default",
},
{
label: "CSS",
value: "css",
},
{
label: "Pick",
value: "pick",
},
];
enum SubMode {
hleft = "start",
hcenter = "center",
Expand Down
23 changes: 5 additions & 18 deletions src/ui/src/builder/settings/BuilderFieldsColor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,11 @@ import { Component } from "@/writerTypes";
import { useComponentActions } from "../useComponentActions";
import injectionKeys from "../../injectionKeys";
import BuilderTemplateInput from "./BuilderTemplateInput.vue";
import WdsTabs, { WdsTabOptions } from "@/wds/WdsTabs.vue";
type Mode = "pick" | "css" | "default";
const tabs: WdsTabOptions<Mode>[] = [
{
label: "Default",
value: "default",
},
{
label: "CSS",
value: "css",
},
{
label: "Pick",
value: "pick",
},
];
import WdsTabs from "@/wds/WdsTabs.vue";
import {
BuilderFieldCssMode as Mode,
BUILDER_FIELD_CSS_TAB_OPTIONS as tabs,
} from "./constants/builderFieldsCssTabs";
const wf = inject(injectionKeys.core);
const ssbm = inject(injectionKeys.builderManager);
Expand Down
23 changes: 5 additions & 18 deletions src/ui/src/builder/settings/BuilderFieldsPadding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ import injectionKeys from "@/injectionKeys";
import BuilderSelect from "../BuilderSelect.vue";
import BuilderTemplateInput from "./BuilderTemplateInput.vue";
import WdsTextInput from "@/wds/WdsTextInput.vue";
import WdsTabs, { WdsTabOptions } from "@/wds/WdsTabs.vue";
import WdsTabs from "@/wds/WdsTabs.vue";
import {
BuilderFieldCssMode as Mode,
BUILDER_FIELD_CSS_TAB_OPTIONS as tabs,
} from "./constants/builderFieldsCssTabs";
const wf = inject(injectionKeys.core);
const ssbm = inject(injectionKeys.builderManager);
Expand All @@ -129,23 +133,6 @@ const pickerEl: Ref<HTMLInputElement> = ref(null);
const fixedEl = ref<ComponentInstance<typeof WdsTextInput>>(null);
const freehandInputEl: Ref<HTMLInputElement> = ref(null);
type Mode = "pick" | "css" | "default";
const tabs: WdsTabOptions<Mode>[] = [
{
label: "Default",
value: "default",
},
{
label: "CSS",
value: "css",
},
{
label: "Pick",
value: "pick",
},
];
enum SubMode {
all_sides = "all_sides",
xy_sides = "XY sides",
Expand Down
23 changes: 5 additions & 18 deletions src/ui/src/builder/settings/BuilderFieldsShadow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ import { Component } from "@/writerTypes";
import { useComponentActions } from "../useComponentActions";
import injectionKeys from "../../injectionKeys";
import BuilderTemplateInput from "./BuilderTemplateInput.vue";
import WdsTabs, { WdsTabOptions } from "@/wds/WdsTabs.vue";
import WdsTabs from "@/wds/WdsTabs.vue";
import {
BuilderFieldCssMode as Mode,
BUILDER_FIELD_CSS_TAB_OPTIONS as tabs,
} from "./constants/builderFieldsCssTabs";
const wf = inject(injectionKeys.core);
const ssbm = inject(injectionKeys.builderManager);
Expand All @@ -128,23 +132,6 @@ const paramBlurRadiusEl: Ref<HTMLInputElement> = ref(null);
const paramSpreadRadiusEl: Ref<HTMLInputElement> = ref(null);
const paramColorEl: Ref<HTMLInputElement> = ref(null);
type Mode = "pick" | "css" | "default";
const tabs: WdsTabOptions<Mode>[] = [
{
label: "Default",
value: "default",
},
{
label: "CSS",
value: "css",
},
{
label: "Pick",
value: "pick",
},
];
const focusEls: Record<Mode, Ref<HTMLInputElement>> = {
pick: paramOffsetXEl,
css: freehandInputEl,
Expand Down
23 changes: 5 additions & 18 deletions src/ui/src/builder/settings/BuilderFieldsWidth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ import injectionKeys from "../../injectionKeys";
import BuilderSelect from "../BuilderSelect.vue";
import BuilderTemplateInput from "./BuilderTemplateInput.vue";
import WdsTextInput from "@/wds/WdsTextInput.vue";
import WdsTabs, { WdsTabOptions } from "@/wds/WdsTabs.vue";
import WdsTabs from "@/wds/WdsTabs.vue";
import {
BuilderFieldCssMode as Mode,
BUILDER_FIELD_CSS_TAB_OPTIONS as tabs,
} from "./constants/builderFieldsCssTabs";
const wf = inject(injectionKeys.core);
const ssbm = inject(injectionKeys.builderManager);
Expand All @@ -68,23 +72,6 @@ const pickerEl: Ref<HTMLInputElement> = ref(null);
const fixedEl = ref<ComponentInstance<typeof WdsTextInput>>(null);
const freehandInputEl: Ref<HTMLInputElement> = ref(null);
type Mode = "pick" | "css" | "default";
const tabs: WdsTabOptions<Mode>[] = [
{
label: "Default",
value: "default",
},
{
label: "CSS",
value: "css",
},
{
label: "Pick",
value: "pick",
},
];
enum SubMode {
fixed = "fixed",
fit_content = "fit-content",
Expand Down
20 changes: 20 additions & 0 deletions src/ui/src/builder/settings/constants/builderFieldsCssTabs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { WdsTabOptions } from "@/wds/WdsTabs.vue";

export type BuilderFieldCssMode = "pick" | "css" | "default";

export const BUILDER_FIELD_CSS_TAB_OPTIONS = Object.freeze<
WdsTabOptions<BuilderFieldCssMode>[]
>([
{
label: "Default",
value: "default",
},
{
label: "CSS",
value: "css",
},
{
label: "Pick",
value: "pick",
},
]);

0 comments on commit da30777

Please sign in to comment.