feat(instances): responsive layout for instance name card

fixes #1118
This commit is contained in:
Fábio Moreira 2018-05-24 10:34:55 +01:00 committed by Sérgio Ramos
parent b66f761a9e
commit 5cb02d709c
3 changed files with 134 additions and 50 deletions

View File

@ -15,6 +15,10 @@ exports[`renders <List /> without throwing 1`] = `
} }
.c31 { .c31 {
padding: 1.125rem;
}
.c32 {
padding: 1.875rem; padding: 1.875rem;
} }
@ -928,6 +932,10 @@ exports[`renders <List /> without throwing 1`] = `
className="c30 c29" className="c30 c29"
disabled={false} disabled={false}
name="card-outlet" name="card-outlet"
>
<span
name="react-responsive-mock"
query="only screen and (max-width: 37.4375rem)"
> >
<div <div
className="c31" className="c31"
@ -935,6 +943,18 @@ exports[`renders <List /> without throwing 1`] = `
You haven't created any instances yet, but they're really easy to set up. You haven't created any instances yet, but they're really easy to set up.
Click above to get going. Click above to get going.
</div> </div>
</span>
<span
name="react-responsive-mock"
query="only screen and (min-width: 37.5rem)"
>
<div
className="c32"
>
You haven't created any instances yet, but they're really easy to set up.
Click above to get going.
</div>
</span>
</div> </div>
</div> </div>
</div> </div>
@ -959,6 +979,10 @@ exports[`renders <List error /> without throwing 1`] = `
} }
.c38 { .c38 {
padding: 1.125rem;
}
.c39 {
padding: 1.875rem; padding: 1.875rem;
} }
@ -1941,6 +1965,10 @@ exports[`renders <List error /> without throwing 1`] = `
className="c37 c36" className="c37 c36"
disabled={false} disabled={false}
name="card-outlet" name="card-outlet"
>
<span
name="react-responsive-mock"
query="only screen and (max-width: 37.4375rem)"
> >
<div <div
className="c38" className="c38"
@ -1948,6 +1976,18 @@ exports[`renders <List error /> without throwing 1`] = `
You haven't created any instances yet, but they're really easy to set up. You haven't created any instances yet, but they're really easy to set up.
Click above to get going. Click above to get going.
</div> </div>
</span>
<span
name="react-responsive-mock"
query="only screen and (min-width: 37.5rem)"
>
<div
className="c39"
>
You haven't created any instances yet, but they're really easy to set up.
Click above to get going.
</div>
</span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -33,6 +33,9 @@ import {
import GetRandomName from '../graphql/get-random-name.gql'; import GetRandomName from '../graphql/get-random-name.gql';
import { Forms, Values } from '../constants'; import { Forms, Values } from '../constants';
import { instanceName as validateName } from '../validators'; import { instanceName as validateName } from '../validators';
import { QueryBreakpoints } from 'joyent-ui-toolkit';
const { SmallOnly, Medium } = QueryBreakpoints;
const { IR_NAME_F } = Forms; const { IR_NAME_F } = Forms;
const { IR_NAME_V_USE_RANDOM } = Values; const { IR_NAME_V_USE_RANDOM } = Values;
@ -61,7 +64,7 @@ const Name = ({
isValid={handleValidate(preview)} isValid={handleValidate(preview)}
{...props} {...props}
> >
<StepHeader icon={<NameIcon />}>Name this instance</StepHeader> <StepHeader icon={<NameIcon />}>Instance name</StepHeader>
<StepDescription> <StepDescription>
Your instance name will be used to identify this specific instance. Your instance name will be used to identify this specific instance.
</StepDescription> </StepDescription>
@ -87,6 +90,33 @@ const Name = ({
<FormGroup id={'input-name'} name="name" fluid field={Field}> <FormGroup id={'input-name'} name="name" fluid field={Field}>
<FormLabel>Instance name</FormLabel> <FormLabel>Instance name</FormLabel>
<Margin top="0.5"> <Margin top="0.5">
<SmallOnly>
<Flex column>
<FlexItem>
<Input onBlur={null} fluid />
</FlexItem>
<FlexItem>
<Margin top="2">
<Button
id={'randomize-button-name'}
type="button"
loading={randomizing}
onClick={handleRandomize}
marginless
secondary
icon
fluid
>
<Margin right="1">
<RandomizeIcon />
</Margin>
Randomize
</Button>
</Margin>
</FlexItem>
</Flex>
</SmallOnly>
<Medium>
<Flex> <Flex>
<FlexItem> <FlexItem>
<Input onBlur={null} /> <Input onBlur={null} />
@ -110,6 +140,7 @@ const Name = ({
</Margin> </Margin>
</FlexItem> </FlexItem>
</Flex> </Flex>
</Medium>
</Margin> </Margin>
<FormMeta /> <FormMeta />
</FormGroup> </FormGroup>

View File

@ -19,6 +19,10 @@ import {
import { Saved as SavedIcon, Error as ErrorIcon } from './status-icon'; import { Saved as SavedIcon, Error as ErrorIcon } from './status-icon';
import { QueryBreakpoints } from 'joyent-ui-toolkit';
const { SmallOnly, Medium } = QueryBreakpoints;
const Card = styled(BaseCard)` const Card = styled(BaseCard)`
${is('error')` ${is('error')`
border: ${remcalc(1)} solid ${props => props.theme.redDark}; border: ${remcalc(1)} solid ${props => props.theme.redDark};
@ -46,13 +50,16 @@ export const Header = ({ icon = null, children }) => (
<Flex justifyBetween> <Flex justifyBetween>
<FlexItem> <FlexItem>
<Flex alignCenter> <Flex alignCenter>
<Medium>
<FlexItem> <FlexItem>
<Margin right="2">{icon}</Margin> <Margin right="2">{icon}</Margin>
</FlexItem> </FlexItem>
</Medium>
<FlexItem> <FlexItem>
<H3 bold>{children}</H3> <H3 bold>{children}</H3>
</FlexItem> </FlexItem>
{/* improve this */} {/* improve this */}
<Medium>
{optional ? ( {optional ? (
<Fragment> <Fragment>
<FlexItem> <FlexItem>
@ -65,6 +72,7 @@ export const Header = ({ icon = null, children }) => (
</FlexItem> </FlexItem>
</Fragment> </Fragment>
) : null} ) : null}
</Medium>
</Flex> </Flex>
</FlexItem> </FlexItem>
<FlexItem alignCenter> <FlexItem alignCenter>
@ -168,7 +176,12 @@ export default class Step extends PureComponent {
> >
<Card expanded={expanded} error={!expanded && !isValid}> <Card expanded={expanded} error={!expanded && !isValid}>
<CardOutlet> <CardOutlet>
<SmallOnly>
<Padding all="3">{children}</Padding>
</SmallOnly>
<Medium>
<Padding all="5">{children}</Padding> <Padding all="5">{children}</Padding>
</Medium>
</CardOutlet> </CardOutlet>
</Card> </Card>
</Broadcast> </Broadcast>