Skip to content

Commit

Permalink
Adjust InputLabel widths (#1034)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Valdivia <[email protected]>
  • Loading branch information
dvaldivia authored Oct 17, 2024
1 parent 7071aec commit fb72b3b
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/components/Checkbox/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Default.args = {
console.log("click");
},
tooltip: "test",
checkLabel: "Yes",
};

export const Disabled = Template.bind({});
Expand Down
38 changes: 23 additions & 15 deletions src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const Checkbox: FC<
helpTip,
helpTipPlacement,
checked,
checkLabel,
disabled,
...props
}) => {
Expand All @@ -162,28 +163,18 @@ const Checkbox: FC<
alignItems: "center",
flexBasis: "initial",
flexWrap: "nowrap",
"& .checkArea": {
display: "flex",
gap: 16,
alignItems: "center",
},
}}
>
<CheckboxItem sx={sx} onClick={(e) => e.stopPropagation()}>
<input
type={"checkbox"}
id={id}
checked={checked}
disabled={disabled}
{...props}
/>
<span className={"checkbox"}>
<CheckIcon className={`${disabled ? "disabled" : ""} icon-overlay`} />
</span>
</CheckboxItem>
{label !== "" && (
<InputLabel
htmlFor={id}
noMinWidth
className={`${overrideLabelClasses || ""}`}
sx={{
marginLeft: 10,
}}
helpTip={helpTip}
helpTipPlacement={helpTipPlacement}
>
Expand All @@ -197,6 +188,23 @@ const Checkbox: FC<
)}
</InputLabel>
)}
<CheckboxItem
className={"checkArea"}
sx={sx}
onClick={(e) => e.stopPropagation()}
>
<input
type={"checkbox"}
id={id}
checked={checked}
disabled={disabled}
{...props}
/>
<span className={"checkbox"}>
<CheckIcon className={`${disabled ? "disabled" : ""} icon-overlay`} />
</span>
{checkLabel && <span>{checkLabel}</span>}
</CheckboxItem>
</FieldContainer>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/components/Checkbox/Checkbox.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export interface CheckboxProps extends HTMLAttributes<HTMLInputElement> {
sx?: OverrideTheme;
helpTip?: React.ReactNode;
helpTipPlacement?: CommonHelpTipPlacement;
checkLabel?: string;
}
4 changes: 3 additions & 1 deletion src/components/InputLabel/InputLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const CustomLabel = styled.label<InputLabelProps>(
display: "flex",
alignItems: "center",
lineHeight: lineHeightVariant,
minWidth: 180,
width: 190,
paddingRight: 8,
textWrap: "wrap",
"&.noMinWidthLabel": {
minWidth: "initial",
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/RadioGroup/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ const OptionsContainer = styled.div<OptionsContainerProps>(
const RadioContainer = styled.div(() => ({
display: "flex",
alignItems: "center",
gap: 5,
gap: 16,
}));

const RadioMain = styled.div(() => ({
"& .descriptionLabel": {
display: "block",
marginLeft: 21,
paddingLeft: 32,
marginTop: 4,
},
}));
Expand Down
7 changes: 6 additions & 1 deletion src/components/ScreenTitle/ScreenTitle.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import ButtonGroup from "../ButtonGroup/ButtonGroup";
import { GlobalStyles } from "../index";
import ScreenTitle from "./ScreenTitle";
import { ScreenTitleProps } from "./ScreenTitle.types";
import Badge from "../Badge/Badge";

export default {
title: "MDS/Layout/ScreenTitle",
Expand All @@ -43,8 +44,12 @@ export const Default = Template.bind({});
Default.args = {
title: "Object Title",
superTitle: "Super Title",
titleBadges: [
<Badge label={"online"} id={"online-badge"} />,
<Badge label={"important"} color={"warning"} id={"important-badge"} />,
],
titleOptions: [
{ title: "Created", value: "Wed, Feb 28 2024 · 23:56:02" },
{ title: "Created", value: "Yesterday" },
{ title: "Access", value: "PUBLIC" },
],
actions: (
Expand Down
21 changes: 19 additions & 2 deletions src/components/ScreenTitle/ScreenTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { FC, HTMLAttributes } from "react";
import React, { FC, Fragment, HTMLAttributes } from "react";
import get from "lodash/get";
import styled from "styled-components";

Expand Down Expand Up @@ -66,6 +66,10 @@ const ScreenTitleContainer = styled.div<ScreenTitleContainerProps>(
"& .subTitle, .superTitle": {
color: theme.colors["Color/Neutral/Text/colorTextQuaternary"],
},
"& .superTitle": {
position: "absolute",
marginTop: -44,
},
},
"& .leftItems": {
flexGrow: 1,
Expand All @@ -75,6 +79,11 @@ const ScreenTitleContainer = styled.div<ScreenTitleContainerProps>(
"& .titleColumn": {
flexGrow: "1",
},
"& .badges": {
display: "flex",
alignItems: "center",
gap: 4,
},
"& .options": {
display: "flex",
alignItems: "center",
Expand Down Expand Up @@ -127,6 +136,7 @@ const ScreenTitle: FC<ScreenTitleProps & HTMLAttributes<HTMLDivElement>> = ({
actions,
sx,
titleOptions,
titleBadges,
...restProps
}) => {
return (
Expand Down Expand Up @@ -155,13 +165,20 @@ const ScreenTitle: FC<ScreenTitleProps & HTMLAttributes<HTMLDivElement>> = ({
) : null}
<Box className={"titleColumn"}>
{superTitle && (
<span className={"superTitle SM_Normal"}>{superTitle}</span>
<div className={"superTitle SM_Normal"}>{superTitle}</div>
)}
<Box className={"titleElement Heading3"}>{title}</Box>
{subTitle && (
<span className={"subTitle SM_Normal"}>{subTitle}</span>
)}
</Box>
{titleBadges && (
<Box className={"badges"}>
{titleBadges?.map((optionItem, index) => (
<Fragment key={`badge-${index}`}>{optionItem}</Fragment>
))}
</Box>
)}
{titleOptions && (
<Box className={"options"}>
{titleOptions?.map((optionItem, index) => (
Expand Down
3 changes: 2 additions & 1 deletion src/components/ScreenTitle/ScreenTitle.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface ScreenTitleProps {
subTitle?: React.ReactNode;
title: string;
actions?: React.ReactNode;
titleBadges?: React.ReactNode[];
titleOptions?: ScreenTitleOptions[];
sx?: OverrideTheme;
}
Expand All @@ -37,6 +38,6 @@ export interface ScreenTitleContainerProps {
}

export interface ScreenTitleOptions {
title: string;
title?: string;
value?: string;
}

0 comments on commit fb72b3b

Please sign in to comment.