Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/use-label-for-fields' in…
Browse files Browse the repository at this point in the history
…to alpha
  • Loading branch information
mguellsegarra committed Oct 11, 2024
2 parents d4ff533 + 4578f4d commit 5a0d8c1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/widgets/base/Label.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React from "react";
import React, { useContext } from "react";
import { Tooltip, Typography, theme } from "antd";
import { WidgetProps } from "@/types";
import { QuestionCircleOutlined } from "@ant-design/icons";
import { Label as LabelOoui } from "@gisce/ooui";
import { FormContext, FormContextType } from "@/context/FormContext";
import { Interweave } from "interweave";
const { Text, Title } = Typography;
const { useToken } = theme;

type Props = WidgetProps & {
ooui: LabelOoui;
align?: "left" | "center" | "right";
responsiveBehaviour?: boolean;
};
Expand All @@ -20,10 +22,13 @@ const alignClass = {

const Label = (props: Props) => {
const { ooui, align, responsiveBehaviour } = props;
const { label, tooltip, fieldForLabel, labelSize, labelType } =
ooui as LabelOoui;
const { label, tooltip, fieldForLabel, labelSize, labelType } = ooui;
const formContext = useContext(FormContext) as FormContextType;
const addColon = fieldForLabel !== null;
const labelText = addColon && label.length > 1 ? label + " :" : label;
let labelText = addColon && label.length > 1 ? label + " :" : label;
if (!ooui.fieldForLabel && ooui._id) {
labelText = formContext.getFieldValue(ooui._id);
}
const responsiveAlign = responsiveBehaviour ? "left" : "right";
const labelAlgin = align || (fieldForLabel ? responsiveAlign : "left");
const { token } = useToken();
Expand Down

0 comments on commit 5a0d8c1

Please sign in to comment.