Skip to content

Commit

Permalink
Refactor: get rid of half implemented hasMargin prop
Browse files Browse the repository at this point in the history
  • Loading branch information
emielvanseveren committed Aug 2, 2024
1 parent ad83637 commit 200ec63
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 18 deletions.
2 changes: 0 additions & 2 deletions packages/lib-components/src/components/inputs/InputProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ interface DefaultInputProps {
readOnly?: boolean;
disabled?: boolean;
size?: Size;
hasMargin?: boolean;
}

type Required<T> = {
Expand All @@ -53,7 +52,6 @@ export const defaultInputProps: Required<DefaultInputProps> = {
readOnly: false,
disabled: false,
size: 'medium',
hasMargin: true,
};

export function defaultInputPropsFactory<T extends InputProps>(defaultValues: Required<DefaultInputProps>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type ControlledRadioGroupProps = PropsWithChildren<ControlledInputProps>;
const defaultsApplier = defaultInputPropsFactory<ControlledRadioGroupProps>(defaultInputProps);

export const ControlledRadioGroup: FC<ControlledRadioGroupProps> & RadioGroupSubComponents = (props) => {
const { name, control, description, children, disabled, readOnly, required, hasMargin } = defaultsApplier(props);
const { name, control, description, children, disabled, readOnly, required } = defaultsApplier(props);

const {
field,
Expand All @@ -32,7 +32,6 @@ export const ControlledRadioGroup: FC<ControlledRadioGroupProps> & RadioGroupSub
hasError={!!error}
required={required}
hasDescription={!!description}
hasMargin={hasMargin}
>
{children}
</GenericRadioGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { styled } from '../../../styled';

export const InputWrapper = styled.div<{ marginBottom?: string }>`
export const InputWrapper = styled.div`
width: 100%;
margin-bottom: ${({ theme, marginBottom }) => (marginBottom ? marginBottom : theme.spacing[2])};
margin-bottom: ${({ theme }) => theme.spacing[2]};
`;
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const ControlledSelectField: FC<ControlledSelectFieldProps> & SubComponen
enableFilter,
inPortal,
canClear,
hasMargin = true,
} = defaultsApplier(props);

const {
Expand Down Expand Up @@ -81,7 +80,7 @@ export const ControlledSelectField: FC<ControlledSelectFieldProps> & SubComponen
}

return (
<InputWrapper marginBottom={hasMargin ? undefined : '0'}>
<InputWrapper>
<Container>
{label && (
<Label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export const Default: StoryFn<ItemSelectQueryViewProps> = (args) => {
name="item"
label="Item"
required={args.required}
hasMargin={args.hasMargin}
readOnly={args.readOnly}
loading={args.loading}
disabled={args.disabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const ItemSelect: FC<ItemSelectProps> = ({
inPortal,
readOnly,
required,
hasMargin,
description,
placeholder = 'Select an item',
gameServerId,
Expand Down Expand Up @@ -84,7 +83,6 @@ export const ItemSelect: FC<ItemSelectProps> = ({
inPortal={inPortal}
hint={hint}
multiple={multiple}
hasMargin={hasMargin}
placeholder={placeholder}
required={required}
loading={loading}
Expand Down Expand Up @@ -112,7 +110,6 @@ export const ItemSelectQueryView: FC<ItemSelectQueryViewProps> = ({
size,
disabled,
placeholder,
hasMargin,
multiple,
inPortal,
hint,
Expand Down Expand Up @@ -152,7 +149,6 @@ export const ItemSelectQueryView: FC<ItemSelectQueryViewProps> = ({
readOnly={readOnly}
required={required}
multiple={multiple}
hasMargin={hasMargin}
description={description}
canClear={canClear}
render={(selectedItems) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const PlayerSelectQuery: FC<CustomQuerySelectProps> = ({
inPortal,
readOnly,
required,
hasMargin,
description,
placeholder = 'Select a player',
multiple,
Expand All @@ -49,7 +48,6 @@ export const PlayerSelectQuery: FC<CustomQuerySelectProps> = ({
inPortal={inPortal}
hint={hint}
multiple={multiple}
hasMargin={hasMargin}
placeholder={placeholder}
required={required}
loading={loading}
Expand All @@ -74,7 +72,6 @@ export const PlayerSelectQueryView: FC<PlayerSelectQueryViewProps> = ({
size,
disabled,
placeholder,
hasMargin,
multiple,
inPortal,
hint,
Expand All @@ -98,7 +95,6 @@ export const PlayerSelectQueryView: FC<PlayerSelectQueryViewProps> = ({
readOnly={readOnly}
required={required}
multiple={multiple}
hasMargin={hasMargin}
description={description}
render={(selectedPlayers) => {
if (selectedPlayers.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export const ShopListingBuyForm: FC<ShopListingBuyFormProps> = ({
label="Amount"
type="number"
placeholder="Enter amount"
hasMargin={false}
/>
<Button
isLoading={isPendingShopOrderCreate}
Expand Down

0 comments on commit 200ec63

Please sign in to comment.