Skip to content
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 25 additions & 2 deletions packages/ui/src/radio/RadioField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import {
Switch,
TextField,
} from '@material-ui/core';
import { AccountBoxOutlined, Error, VerifiedUser } from '@material-ui/icons';
import { AccountBoxOutlined, Error } from '@material-ui/icons';
import { UseState } from '@superdispatch/ui-docs';
import {
CheckboxField,
CollapseProp,
Column,
Columns,
Image,
Inline,
RadioField,
RadioFieldCard,
RadioGroupField,
Stack,
Tag,
} from '..';

export default { title: 'Inputs/RadioField', component: RadioField };
Expand Down Expand Up @@ -197,7 +200,27 @@ export const radioGroupCard = () => {
name: 'driver_dispatcher',
label: 'I Drive And Dispatch',
caption: 'I use both Carrier TMS and Driver App.',
icon: <VerifiedUser />,
icon: <Image src="https://dummyimage.com/72x72/7a7a7a/fff" />,
collapseIconBelow: 'tablet' as CollapseProp,
},
{
value: 'truck',
name: 'truck',
label: 'Im truck',
caption: 'Im truck',
icon: <Image src="https://dummyimage.com/144x72/7a7a7a/fff" />,
collapseIconBelow: 'tablet' as CollapseProp,
},
{
value: 'tag',
name: 'tag',
label: 'Im tag',
caption: 'Im tag',
icon: (
<Tag variant="subtle" color="grey">
Verified
</Tag>
),
},
];

Expand Down
18 changes: 14 additions & 4 deletions packages/ui/src/radio/RadioFieldCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Radio,
Typography,
} from '@material-ui/core';
import { forwardRef, ForwardRefExoticComponent } from 'react';
import { forwardRef, ForwardRefExoticComponent, ReactNode } from 'react';
import styled from 'styled-components';
import { Column } from '../columns/Column';
import { Columns } from '../columns/Columns';
Expand Down Expand Up @@ -40,12 +40,20 @@ const Caption = styled.div`
padding-left: 30px;
`;

const IconWrapper = styled.div`
display: flex;

${({ theme }) => theme.breakpoints.down('xs')} {
padding-left: 30px;
}
`;

export interface RadioCardItemProps {
value: string;
label: string;
name?: string;
caption?: string;
icon?: React.ReactNode;
icon?: ReactNode;
}

interface RadioCardProps
Expand Down Expand Up @@ -75,7 +83,7 @@ export const RadioFieldCard: ForwardRefExoticComponent<RadioCardProps> =
<Card disabled={disabled} key={value}>
<ClickableCard name={name} disabled={disabled} {...props}>
<Content active={checked}>
<Columns space="small">
<Columns collapseBelow="tablet" space="small">
<Column>
<FormControlLabel
value={value}
Expand All @@ -90,7 +98,9 @@ export const RadioFieldCard: ForwardRefExoticComponent<RadioCardProps> =
</Caption>
</Column>

<Column width="content">{icon}</Column>
<Column width="content">
<IconWrapper>{icon}</IconWrapper>
</Column>
</Columns>
</Content>
</ClickableCard>
Expand Down
Loading