Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from "@testing-library/react";
import { CurrentTask } from "../CurrentTask";
import { BlockContext, cn } from "../../../utils/bem.ts";
import { FF_LEAP_1173 } from "../../../utils/feature-flags";
import { mockFF } from "../../../../__mocks__/global";

Expand Down Expand Up @@ -53,11 +52,7 @@ describe("CurrentTask", () => {
["skip", "postpone", "topbar:prevnext", "topbar:task-counter"].includes(interfaceName),
);

const { rerender, getByTestId } = render(
<BlockContext.Provider value={cn("block-name")}>
<CurrentTask store={store} />
</BlockContext.Provider>,
);
const { rerender, getByTestId } = render(<CurrentTask store={store} />);

expect(getByTestId("next-task").disabled).toBe(false);

Expand All @@ -71,11 +66,7 @@ describe("CurrentTask", () => {
),
};

rerender(
<BlockContext.Provider value={cn("block-name")}>
<CurrentTask store={store} />
</BlockContext.Provider>,
);
rerender(<CurrentTask store={store} />);

expect(getByTestId("next-task").disabled).toBe(true);

Expand All @@ -89,11 +80,7 @@ describe("CurrentTask", () => {
),
};

rerender(
<BlockContext.Provider value={cn("block-name")}>
<CurrentTask store={store} />
</BlockContext.Provider>,
);
rerender(<CurrentTask store={store} />);

expect(getByTestId("next-task").disabled).toBe(true);

Expand All @@ -107,11 +94,7 @@ describe("CurrentTask", () => {
),
};

rerender(
<BlockContext.Provider value={cn("block-name")}>
<CurrentTask store={store} />
</BlockContext.Provider>,
);
rerender(<CurrentTask store={store} />);

expect(getByTestId("next-task").disabled).toBe(true);

Expand All @@ -125,11 +108,7 @@ describe("CurrentTask", () => {
),
};

rerender(
<BlockContext.Provider value={cn("block-name")}>
<CurrentTask store={store} />
</BlockContext.Provider>,
);
rerender(<CurrentTask store={store} />);

expect(getByTestId("next-task").disabled).toBe(true);
});
Expand Down
24 changes: 9 additions & 15 deletions web/libs/editor/src/components/Label/Label.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chroma from "chroma-js";
import React, { useMemo } from "react";
import { Block, Elem } from "../../utils/bem";
import { cn } from "../../utils/bem";
import { asVars } from "../../utils/styles";

import "./Label.scss";
Expand Down Expand Up @@ -36,25 +36,19 @@ export const Label = React.forwardRef(
}, [color]);

return (
<Block
tag="span"
<span
ref={ref}
name="label"
mod={{ empty, hidden, selected, clickable: !!onClick, margins }}
mix={className}
className={cn("label")
.mod({ empty, hidden, selected, clickable: !!onClick, margins })
.mix(className)
.toClassName()}
style={styles}
onClick={onClick}
{...rest}
>
<Elem tag="span" name="text">
{children}
</Elem>
{hotkey ? (
<Elem tag="span" name="hotkey">
{hotkey}
</Elem>
) : null}
</Block>
<span className={cn("label").elem("text").toClassName()}>{children}</span>
{hotkey ? <span className={cn("label").elem("hotkey").toClassName()}>{hotkey}</span> : null}
</span>
);
},
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from "@testing-library/react";
import { CurrentTask } from "../CurrentTask";
import { BlockContext, cn } from "../../../utils/bem.ts";
import { FF_LEAP_1173 } from "../../../utils/feature-flags";
import { mockFF } from "../../../../__mocks__/global";

Expand Down Expand Up @@ -53,11 +52,7 @@ describe("CurrentTask", () => {
["skip", "postpone", "topbar:prevnext", "topbar:task-counter"].includes(interfaceName),
);

const { rerender, getByTestId } = render(
<BlockContext.Provider value={cn("block-name")}>
<CurrentTask store={store} />
</BlockContext.Provider>,
);
const { rerender, getByTestId } = render(<CurrentTask store={store} />);

expect(getByTestId("next-task").disabled).toBe(false);

Expand All @@ -71,11 +66,7 @@ describe("CurrentTask", () => {
),
};

rerender(
<BlockContext.Provider value={cn("block-name")}>
<CurrentTask store={store} />
</BlockContext.Provider>,
);
rerender(<CurrentTask store={store} />);

expect(getByTestId("next-task").disabled).toBe(true);

Expand All @@ -89,11 +80,7 @@ describe("CurrentTask", () => {
),
};

rerender(
<BlockContext.Provider value={cn("block-name")}>
<CurrentTask store={store} />
</BlockContext.Provider>,
);
rerender(<CurrentTask store={store} />);

expect(getByTestId("next-task").disabled).toBe(true);

Expand All @@ -107,11 +94,7 @@ describe("CurrentTask", () => {
),
};

rerender(
<BlockContext.Provider value={cn("block-name")}>
<CurrentTask store={store} />
</BlockContext.Provider>,
);
rerender(<CurrentTask store={store} />);

expect(getByTestId("next-task").disabled).toBe(true);

Expand All @@ -125,11 +108,7 @@ describe("CurrentTask", () => {
),
};

rerender(
<BlockContext.Provider value={cn("block-name")}>
<CurrentTask store={store} />
</BlockContext.Provider>,
);
rerender(<CurrentTask store={store} />);

expect(getByTestId("next-task").disabled).toBe(true);
});
Expand Down
37 changes: 21 additions & 16 deletions web/libs/editor/src/tags/control/Choice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Types from "../../core/Types";
import { AnnotationMixin } from "../../mixins/AnnotationMixin";
import { TagParentMixin } from "../../mixins/TagParentMixin";
import { FF_DEV_3391, isFF } from "../../utils/feature-flags";
import { Block, Elem } from "../../utils/bem";
import { cn } from "../../utils/bem";
import "./Choice/Choice.scss";
import { IconChevron } from "@humansignal/ui";
import { HintTooltip } from "../../components/Taxonomy/Taxonomy";
Expand Down Expand Up @@ -194,16 +194,17 @@ const HtxNewChoiceView = ({ item, store }) => {
const [collapsed, setCollapsed] = useState(false);
const toogleCollapsed = useCallback(() => setCollapsed((collapsed) => !collapsed), []);

const CheckboxComponent = nameWrapper(item.isCheckbox ? Checkbox : Radio, item._value);

return (
<Block
name="choice"
mod={{ layout: item.parent.layout, leaf: item.isLeaf, notLeaf: !item.isLeaf, hidden: !item.visible }}
<div
className={cn("choice")
.mod({ layout: item.parent.layout, leaf: item.isLeaf, notLeaf: !item.isLeaf, hidden: !item.visible })
.toClassName()}
>
<Elem name="item" mod={{ notLeaf: !item.isLeaf }} style={style}>
<Elem
name="checkbox"
component={nameWrapper(item.isCheckbox ? Checkbox : Radio, item._value)}
mod={{ notLeaf: !item.isLeaf }}
<div className={cn("choice").elem("item").mod({ notLeaf: !item.isLeaf }).toClassName()} style={style}>
<CheckboxComponent
className={cn("choice").elem("checkbox").mod({ notLeaf: !item.isLeaf }).toClassName()}
checked={item.sel}
indeterminate={!item.sel && item.indeterminate}
disabled={item.isReadOnly()}
Expand All @@ -213,21 +214,25 @@ const HtxNewChoiceView = ({ item, store }) => {
{item.html ? <span dangerouslySetInnerHTML={{ __html: sanitizeHtml(item.html) }} /> : item._value}
{showHotkey && <Hint>[{item.hotkey}]</Hint>}
</HintTooltip>
</Elem>
</CheckboxComponent>
{!item.isLeaf ? (
<Elem name="toggle" mod={{ collapsed }} component={Button} type="text" onClick={toogleCollapsed}>
<Button
className={cn("choice").elem("toggle").mod({ collapsed }).toClassName()}
type="text"
onClick={toogleCollapsed}
>
<IconChevron />
</Elem>
</Button>
) : (
false
)}
</Elem>
</div>
{item.nestedResults && item.children?.length ? (
<Elem name="children" mod={{ collapsed }}>
<div className={cn("choice").elem("children").mod({ collapsed }).toClassName()}>
{Tree.renderChildren(item, item.annotation)}
</Elem>
</div>
) : null}
</Block>
</div>
);
};

Expand Down
11 changes: 6 additions & 5 deletions web/libs/editor/src/tags/control/Choices.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Types from "../../core/Types";
import { guidGenerator } from "../../core/Helpers";
import ControlBase from "./Base";
import { AnnotationMixin } from "../../mixins/AnnotationMixin";
import { Block } from "../../utils/bem";
import { cn } from "../../utils/bem";
import "./Choices/Choices.scss";

import "./Choice";
Expand Down Expand Up @@ -292,13 +292,14 @@ const ChoicesSelectLayout = observer(({ item }) => {

const HtxChoices = observer(({ item }) => {
return (
<Block
name="choices"
mod={{ hidden: !item.isVisible || !item.perRegionVisible(), layout: item.layout }}
<div
className={cn("choices")
.mod({ hidden: !item.isVisible || !item.perRegionVisible(), layout: item.layout })
.toClassName()}
ref={item.elementRef}
>
{item.layout === "select" ? <ChoicesSelectLayout item={item} /> : Tree.renderChildren(item, item.annotation)}
</Block>
</div>
);
});

Expand Down
6 changes: 3 additions & 3 deletions web/libs/editor/src/tags/control/Labels/Labels.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AnnotationMixin } from "../../../mixins/AnnotationMixin";
import DynamicChildrenMixin from "../../../mixins/DynamicChildrenMixin";
import LabelMixin from "../../../mixins/LabelMixin";
import SelectedModelMixin from "../../../mixins/SelectedModel";
import { Block } from "../../../utils/bem";
import { cn } from "../../../utils/bem";
import ControlBase from "../Base";
import "../Label";
import "./Labels.scss";
Expand Down Expand Up @@ -146,9 +146,9 @@ const LabelsModel = types.compose(

const HtxLabels = observer(({ item }) => {
return (
<Block name="labels" mod={{ hidden: !item.visible, inline: item.showinline }}>
<div className={cn("labels").mod({ hidden: !item.visible, inline: item.showinline }).toClassName()}>
{Tree.renderChildren(item, item.annotation)}
</Block>
</div>
);
});

Expand Down
Loading
Loading