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

Styling updates #1414

Merged
merged 7 commits into from
Feb 27, 2024
Merged
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
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.requireConfig": true,
"editor.codeActionsOnSave": {
"source.fixAll.tslint": true,
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
"source.fixAll.tslint": "explicit",
"source.fixAll.eslint": "explicit",
"source.fixAll.stylelint": "explicit"
}
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "13.6.0",
"version": "13.7.0",
"license": "MIT",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/components/basic-table/__tests__/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const COLUMNS: BasicTableColumn[] = [
},
{
label: 'Actions',
type: BasicTableColumnType.Custom,
type: BasicTableColumnType.Action,
field: 'actions',
},
];
Expand Down
5 changes: 5 additions & 0 deletions src/components/basic-table/components/cell/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export const renderCell = (row: BasicTableRow, column: BasicTableColumn) => {
<>{value}</>
</CellWrapper>
),
[BasicTableColumnType.Action]: () => (
<CellWrapper alignRight>
<>{value}</>
</CellWrapper>
),
[BasicTableColumnType.Financial]: () => (
<CellWrapper alignRight>
<>
Expand Down
1 change: 1 addition & 0 deletions src/components/basic-table/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TableProps } from 'baseui/table-semantic';
export enum BasicTableColumnType {
Text = 'text',
Custom = 'custom',
Action = 'action',
Financial = 'financial',
}

Expand Down
34 changes: 11 additions & 23 deletions src/components/form-group/FormGroup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,15 @@ const Template: Story<FormGroupProps> = ({ title, subtitle }) => {
name="name"
control={control}
rules={{ required: true }}
render={({ field }) => (
<Input
{...field}
testId="name-input"
size="compact"
placeholder="Name"
error={!!errors.name}
autoComplete="off"
/>
)}
render={({ field }) => <Input {...field} placeholder="Name" error={!!errors.name} autoComplete="off" />}
/>
<FormRow
label="This is a label"
caption="This is a caption"
name="name"
control={control}
rules={{ required: true }}
render={({ field }) => (
<Input
{...field}
testId="name-input"
size="compact"
placeholder="Name"
error={!!errors.name}
autoComplete="off"
/>
)}
render={({ field }) => <Input {...field} placeholder="Name" error={!!errors.name} autoComplete="off" />}
/>
<FormRow
label="This is a label"
Expand All @@ -70,9 +52,7 @@ const Template: Story<FormGroupProps> = ({ title, subtitle }) => {
name="name"
control={control}
rules={{ required: true }}
render={({ field }) => (
<Input {...field} testId="name-input" size="compact" placeholder="Name" error autoComplete="off" />
)}
render={({ field }) => <Input {...field} placeholder="Name" error autoComplete="off" />}
/>
<TCFormRow
control={control}
Expand Down Expand Up @@ -103,6 +83,14 @@ const Template: Story<FormGroupProps> = ({ title, subtitle }) => {
</FormGroup>

<FormGroup title={title} subtitle={subtitle}></FormGroup>
<FormGroup>
<FormRow
label="This is a full width form group"
name="name"
control={control}
render={({ field }) => <Input {...field} placeholder="Name" autoComplete="off" />}
/>
</FormGroup>
</>
);
};
Expand Down
15 changes: 4 additions & 11 deletions src/components/form-group/FormGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ import { FormGroupStack, FormGroupTitleStack } from './styles';
import { Separator } from '../separator';

export const FormGroup = ({ title, subtitle, children }: FormGroupProps) => {
const [dimensions, setDimensions] = useState({
width: 0,
height: 0,
});
const [width, setWidth] = useState(0);

const [elementRef, setElementRef] = useState<HTMLElement | null>();

useEffect(() => {
const onWindowResize = () => {
setDimensions({
width: elementRef?.offsetWidth || 0,
height: elementRef?.offsetHeight || 0,
});
setWidth(elementRef?.offsetWidth || 0);
};

if (typeof window !== undefined && elementRef?.offsetWidth) {
Expand All @@ -32,9 +26,9 @@ export const FormGroup = ({ title, subtitle, children }: FormGroupProps) => {
}
}, [elementRef]);

const { width } = dimensions;
const breakpoint = 900;
const isLarge = width ? width > breakpoint : true;
// Only set large if subtitle or title is present
const isLarge = (width > breakpoint && !!(title || subtitle)) ?? false;

const {
theme: {
Expand All @@ -44,7 +38,6 @@ export const FormGroup = ({ title, subtitle, children }: FormGroupProps) => {
},
},
} = useTheme();

const gridGap = useMemo(() => {
if (isLarge) {
return scale1200;
Expand Down
2 changes: 1 addition & 1 deletion src/components/form-group/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { themedStyled } from '../../theme';
export const FormGroupStack = themedStyled('div', ({ $theme }) => ({
display: 'flex',
flexDirection: 'column',
gap: $theme.sizing.scale500,
gap: $theme.sizing.scale750,
}));

export const FormGroupTitleStack = themedStyled('div', ({ $theme }) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/form-row/FormRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const FormRow = <T extends FieldValues, K extends string>({
return (
<Block width={'100%'}>
{label && (
<Block marginBottom={scale300}>
<Block marginBottom={scale100}>
<LabelSmall display="flex" as="label" alignItems="center" gridGap={scale200} for={name as string}>
{getLabel()}
{toolTip && (
Expand Down
1 change: 1 addition & 0 deletions src/components/side-nav/SideNav.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Template: Story<SideNavProps> = () => {
{
id: Tab.General,
title: Tab.General,
subtitle: 'Subtitle',
component: () => <ParagraphSmall>{Tab.General}</ParagraphSmall>,
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/components/side-nav/SideNavListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const SideNavListItem = ({
current: {
colors: { primary, contentSecondary },
customColors: { dark3 },
sizing: { scale400, scale500 },
sizing: { scale100, scale400, scale500, scale600 },
},
},
} = useTheme();
Expand Down Expand Up @@ -80,7 +80,7 @@ export const SideNavListItem = ({
return (
<>
{subtitle && (
<LabelXSmall color={dark3} marginTop={scale500} marginBottom={scale400}>
<LabelXSmall color={dark3} marginTop={scale600} marginBottom={scale100}>
{subtitle.toUpperCase()}
</LabelXSmall>
)}
Expand Down
5 changes: 3 additions & 2 deletions src/components/switcher/Switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ export interface SwitcherProps {
onPrev: () => void;
onNext: () => void;
value: string | number;
color?: string;
}

export const Switcher = ({ onPrev, onNext, value }: SwitcherProps) => {
export const Switcher = ({ onPrev, onNext, value, color }: SwitcherProps) => {
const {
theme: {
current: {
Expand All @@ -27,7 +28,7 @@ export const Switcher = ({ onPrev, onNext, value }: SwitcherProps) => {
<Button onClick={onPrev}>
<CaretLeftIcon size={scale400} />
</Button>
<LabelMedium paddingLeft={scale500} paddingRight={scale500}>
<LabelMedium paddingLeft={scale500} paddingRight={scale500} color={color}>
{value}
</LabelMedium>
<Button onClick={onNext}>
Expand Down
Loading