Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: OPTIC-1332: componetize Toggle and Label components #6723

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1c797de
toggle and label component started
carly-bartel Nov 25, 2024
66f0ad3
debugging toggle
carly-bartel Nov 26, 2024
e341647
swap instances of toggle
carly-bartel Nov 26, 2024
a18ae62
Merge branch 'develop' into 'fb-optic-1332'
yyassi-heartex Nov 29, 2024
c021423
cleanup
yyassi-heartex Nov 29, 2024
c31df4a
more cleanup
yyassi-heartex Nov 29, 2024
8106b04
supporting passed in className
yyassi-heartex Nov 29, 2024
78f0610
cleaning up types and setting safe defaults + brought in alwaysBlue d…
yyassi-heartex Nov 29, 2024
03c90a6
oops - minor correction
yyassi-heartex Nov 29, 2024
3ff5cb6
Update web/apps/labelstudio/src/components/Form/Elements/Label/Label.jsx
yyassi-heartex Dec 2, 2024
eb62f58
Update web/libs/datamanager/src/components/Common/Form/Elements/Label…
yyassi-heartex Dec 2, 2024
baa5208
Update web/libs/ui/src/lib/toggle/toggle.module.scss
yyassi-heartex Dec 3, 2024
b3ebca3
Merge branch 'develop' into 'fb-optic-1332'
MihajloHoma Dec 3, 2024
156a952
Merge branch 'develop' into 'fb-optic-1332'
MihajloHoma Dec 4, 2024
609d196
required label visuals is now slightly smaller with a margin
yyassi-heartex Dec 4, 2024
f6b865d
required default was applying required erronously
yyassi-heartex Dec 4, 2024
ebfd289
Merge branch 'develop' into 'fb-optic-1332'
yyassi-heartex Dec 16, 2024
09ef32c
lint cleanup
yyassi-heartex Dec 16, 2024
d45d8da
Merge branch 'develop' into 'fb-optic-1332'
MihajloHoma Dec 17, 2024
e883478
Merge branch 'develop' into fb-optic-1332
yyassi-heartex Dec 18, 2024
568529e
using exisitng LS Label for now until we unify Label visuals across t…
yyassi-heartex Dec 18, 2024
f79f6e4
Merge branch 'develop' into 'fb-optic-1332'
MihajloHoma Dec 18, 2024
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,7 +1,7 @@
import { createElement } from "react";
import { cn } from "../../../../utils/bem";
import "./Label.scss";

/** @deprecated - needs to be replaced with @humansignal/ui Label - visualizes differently currently */
const Label = ({ text, children, required, placement, description, size, large, style, simple, flat }) => {
const rootClass = cn("label-ls");
const classList = [rootClass];
Expand Down
36 changes: 10 additions & 26 deletions web/apps/labelstudio/src/components/Form/Elements/Toggle/Toggle.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { forwardRef, useEffect, useMemo } from "react";
import { cn } from "../../../../utils/bem";
import { Toggle as UiToggle } from "@humansignal/ui";
import { FormField } from "../../FormField";
import { useValueTracker } from "../../Utils";
import { default as Label } from "../Label/Label";
import "./Toggle.scss";

const Toggle = forwardRef(
(
Expand All @@ -22,22 +21,13 @@ const Toggle = forwardRef(
},
ref,
) => {
const rootClass = cn("toggle");
const initialChecked = useMemo(() => defaultChecked ?? checked ?? false, [defaultChecked, checked]);
const [isChecked, setIsChecked] = useValueTracker(checked, defaultChecked ?? false);

const classList = [rootClass];
const mods = {};

useEffect(() => {
setIsChecked(initialChecked);
}, [initialChecked]);

if (isChecked) mods.checked = isChecked;
mods.disabled = props.disabled;

classList.push(rootClass.mod(mods), className);

const formField = (
<FormField
ref={label ? null : ref}
Expand All @@ -50,24 +40,18 @@ const Toggle = forwardRef(
{...props}
>
{(ref) => (
<div className={classList.join(" ")}>
<input
ref={ref}
{...props}
className={rootClass.elem("input")}
type="checkbox"
checked={isChecked}
onChange={(e) => {
setIsChecked(e.target.checked);
onChange?.(e);
}}
/>
<span className={rootClass.elem("indicator")} />
</div>
<UiToggle
ref={ref}
{...props}
checked={isChecked}
onChange={(e) => {
setIsChecked(e.target.checked);
onChange?.(e);
}}
/>
)}
</FormField>
);

return label ? (
<Label
ref={ref}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion web/apps/labelstudio/src/components/Form/Elements/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ export { default as Label } from "./Label/Label";
export { default as Select } from "./Select/Select";
export { default as TextArea } from "./TextArea/TextArea";
export { default as Toggle } from "./Toggle/Toggle";
export { default as ToggleRight } from "./ToggleRight/ToggleRight";
53 changes: 0 additions & 53 deletions web/apps/labelstudio/src/pages/ExportPage/ExportPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,51 +100,6 @@ export const ExportPage = () => {
}
}, [pageParams]);

// const formatSelect = (
// <Label text="Export format" style={{display: "block", width: "mix-content"}} flat>
// <Dropdown.Trigger content={(
// <Menu size="medium">
// {Object.entries(formats).map(([key, value]) => {
// return <Menu.Item key={key} onClick={() => setFormat(key)}>{value}</Menu.Item>;
// })}
// </Menu>
// )}>
// <Button size="small" style={{textAlign: "left"}}>
// <span>{formats[format]}</span>
// </Button>
// </Dropdown.Trigger>
// </Label>
// );

// const aggregation = (
// <Form.Row columnCount={2}>
// {/* TODO: We don't have api for different formats yet, so let's hide the select for now */}
// {/* {formatSelect} */}

// <RadioGroup label="Aggregation of annotations" size="small" name="aggregator_type" labelProps={{size: "large", flat: true}}>
// <RadioGroup.Button value="majority_vote" checked>
// Majority vote
// </RadioGroup.Button>
// <RadioGroup.Button value="no_aggregation">
// No aggregation
// </RadioGroup.Button>
// </RadioGroup>
// </Form.Row>
// );

// const exportHistory = (
// <Label text="Previous exports" size="large" flat>
// {previousExports.map(file => {
// const basename = file.url.split('/').reverse()[0];
// return (
// <Button key={file.url} href={file.url} size="medium" download={basename} icon={<FaFileDownload/>}>
// {basename}
// </Button>
// );
// })}
// </Label>
// );

return (
<Modal
onHide={() => {
Expand All @@ -169,14 +124,6 @@ export const ExportPage = () => {

<Form ref={form}>
<Input type="hidden" name="exportType" value={currentFormat} />

{/* {aggregation} */}

{/*<Form.Row columnCount={3} style={{marginTop: 24}}>*/}
{/* <Toggle label="Only finished tasks" name="finished" checked/>*/}
{/* <Toggle label="Include full task descriptions" name="return_task" checked/>*/}
{/* <Toggle label="Include predictions" name="return_predictions" checked/>*/}
{/*</Form.Row>*/}
</Form>

<Elem name="footer">
Expand Down
2 changes: 1 addition & 1 deletion web/apps/labelstudio/src/pages/WebhookPage/WebhookList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useCallback } from "react";
import { LsPencil } from "../../assets/icons";
import { IconCross } from "@humansignal/ui";
import { Button } from "../../components";
import { Toggle } from "../../components/Form";
import { Toggle } from "@humansignal/ui";
import { Block, Elem } from "../../utils/bem";
import "./WebhookPage.scss";
import { format } from "date-fns";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { forwardRef } from "react";
import { Block, Elem } from "../../../../../utils/bem";
import "./Label.scss";

/** @deprecated - needs to be replaced with @humansignal/ui Label - visualizes differently currently */
const Label = forwardRef(
({ text, children, required, placement, description, size, large, style, simple, flat }, ref) => {
const tagName = simple ? "div" : "label";
Expand Down
Loading
Loading