Skip to content

Commit

Permalink
fix(dashboard,ui): ConditionBlock styling (#10481)
Browse files Browse the repository at this point in the history
**What**
- Resolves CMRC-58
- Also fixes some other issues, TS errors, Eslint warnings etc. in the Promotion domain. There are still several TS errors as the return types from `@medusajs/types` don't seem to match how they are used here, but I have left that as is, as I am not super familiar with the Promotion module.
  • Loading branch information
kasperkristensen authored Dec 9, 2024
1 parent 3409953 commit c9a66b1
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 134 deletions.
6 changes: 6 additions & 0 deletions .changeset/quick-items-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/ui": patch
"@medusajs/dashboard": patch
---

fix(dashboard,ui): Bring ConditionBlock in line with design
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Separator as PrimitiveSeparator,
} from "@ariakit/react"
import {
CheckMini,
EllipseMiniSolid,
PlusMini,
TrianglesMini,
Expand Down Expand Up @@ -290,7 +291,7 @@ const ComboboxImpl = <T extends Value = string>(
ref={comboboxRef}
onFocus={() => setOpen(true)}
className={clx(
"txt-compact-small text-ui-fg-base placeholder:text-ui-fg-subtle transition-fg size-full cursor-pointer bg-transparent pl-2 pr-8 outline-none focus:cursor-text",
"txt-compact-small text-ui-fg-base !placeholder:text-ui-fg-muted transition-fg size-full cursor-pointer bg-transparent pl-2 pr-8 outline-none focus:cursor-text",
"hover:bg-ui-bg-field-hover",
{
"opacity-0": hideInput,
Expand Down Expand Up @@ -349,7 +350,7 @@ const ComboboxImpl = <T extends Value = string>(
)}
>
<PrimitiveComboboxItemCheck className="flex !size-5 items-center justify-center">
<EllipseMiniSolid />
{isArrayValue ? <CheckMini /> : <EllipseMiniSolid />}
</PrimitiveComboboxItemCheck>
<PrimitiveComboboxItemValue className="txt-compact-small">
{label}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RuleAttributeOptionsResponse, StoreDTO } from "@medusajs/types"
import { Input, Select } from "@medusajs/ui"
import { RefCallBack, useWatch } from "react-hook-form"
import { useWatch } from "react-hook-form"
import { Form } from "../../../../../../components/common/form"
import { Combobox } from "../../../../../../components/inputs/combobox"
import { usePromotionRuleValues } from "../../../../../../hooks/api/promotions"
Expand All @@ -13,9 +13,8 @@ type RuleValueFormFieldType = {
| "application_method.buy_rules"
| "rules"
| "application_method.target_rules"
valuesField: any
operatorsField: any
valuesRef: RefCallBack
name: string
operator: string
fieldRule: any
attributes: RuleAttributeOptionsResponse[]
ruleType: "rules" | "target-rules" | "buy-rules"
Expand All @@ -39,9 +38,8 @@ export const RuleValueFormField = ({
form,
identifier,
scope,
valuesField,
operatorsField,
valuesRef,
name,
operator,
fieldRule,
attributes,
ruleType,
Expand All @@ -65,13 +63,13 @@ export const RuleValueFormField = ({

const watchOperator = useWatch({
control: form.control,
name: operatorsField.name,
name: operator,
})

return (
<Form.Field
key={`${identifier}.${scope}.${valuesField.name}-${fieldRule.attribute}`}
{...valuesField}
key={`${identifier}.${scope}.${name}-${fieldRule.attribute}`}
name={name}
render={({ field: { onChange, ref, ...field } }) => {
if (attribute?.field_type === "number") {
return (
Expand All @@ -82,7 +80,7 @@ export const RuleValueFormField = ({
type="number"
onChange={onChange}
className="bg-ui-bg-base"
ref={valuesRef}
ref={ref}
min={1}
disabled={!fieldRule.attribute}
/>
Expand All @@ -96,6 +94,7 @@ export const RuleValueFormField = ({
<Form.Control>
<Input
{...field}
ref={ref}
onChange={onChange}
className="bg-ui-bg-base"
disabled={!fieldRule.attribute}
Expand Down Expand Up @@ -143,6 +142,7 @@ export const RuleValueFormField = ({
<Form.Control>
<Combobox
{...field}
ref={ref}
placeholder="Select Values"
options={options}
onChange={onChange}
Expand Down
Loading

0 comments on commit c9a66b1

Please sign in to comment.