import React, { Fragment } from 'react';
import { Field } from 'redux-form';
import styled from 'styled-components';
import { Margin, Padding } from 'styled-components-spacing';
import Flex from 'styled-flex-component';
import bytes from 'bytes';
import is, { isNot } from 'styled-is';
import remcalc from 'remcalc';
import {
H3,
H4,
Sup,
FormGroup,
Card,
Button,
TableTh as BaseTableTh,
TableTr,
TableThead as BaseTableThead,
Divider,
TableTbody,
Table,
TableTd as BaseTableTd,
Radio,
Checkbox,
FormLabel,
GeneralIcon,
StorageIcon,
CpuIcon,
MemoryIcon
} from 'joyent-ui-toolkit';
import { NoPackages } from 'joyent-logo-assets';
import { ValueBreakpoints as breakpoints } from 'joyent-ui-toolkit';
import { EmptyState } from 'joyent-icons';
const GroupIcons = {
MEMORY: ,
STORAGE: ,
GENERAL: ,
COMPUTE:
};
const fourDecimals = n => parseFloat(Math.round(n * 10000) / 10000).toFixed(4);
const TableTrActionable = styled(TableTr)`
cursor: pointer;
`;
const NoPackagesTitle = styled(H3)`
color: ${props => props.theme.greyDark};
text-align: center;
`;
const FullWidthCard = styled(Card)`
width: calc(100% - ${remcalc(2)});
${is('transparent')`
background: transparent;
`};
${isNot('borderTop')`
border-top: none;
`};
`;
const TableThead = styled(BaseTableThead)`
${is('smallScreen')`
background-color: transparent;
`};
`;
const TableTh = styled(BaseTableTh)`
@media only screen and (min-width: ${remcalc(
breakpoints.medium.lower
)}) and (max-width: ${remcalc(700)}) {
&:not(:first-child) {
width: auto;
}
padding: 0 ${remcalc(3)};
}
${is('smallScreen')`
border: none;
color: ${props => props.theme.greyDark};
font-size: ${remcalc(13)};
height: auto;
padding: 0;
`};
`;
const TableTd = styled(BaseTableTd)`
@media only screen and (min-width: ${remcalc(
breakpoints.medium.lower
)}) and (max-width: ${remcalc(700)}) {
&:not(:first-child) {
width: auto;
}
padding: 0 ${remcalc(3)};
}
${is('smallScreen')`
border: none;
font-size: ${remcalc(15)};
height: auto;
padding: ${remcalc(4)} 0;
`};
`;
const FormItem = styled('form')`
border: 1px solid ${props => props.theme.grey};
border-radius: 4px;
${is('selected')`
border-color: ${props => props.theme.primary};
background-color: rgba(59,70,204,0.05);
`};
`;
const PackageSpecs = styled('div')`
border-top: 1px solid ${props => props.theme.grey};
${is('selected')`
border-color: ${props => props.theme.primary};
`};
`;
export const Filters = ({ onResetFilters }) => (
Filters
{GroupIcons.COMPUTE}
Compute Optimized
{GroupIcons.MEMORY}
Memory Optimized
{GroupIcons.GENERAL}
General Purpose
{GroupIcons.GENERAL}
Storage Optimized
SSD
);
export const MobilePackage = ({
selected = false,
id,
name,
group,
memory,
price,
vcpus,
disk,
ssd,
hasVms,
sortBy,
onRowClick
}) => (
onRowClick(id)}>
{GroupIcons[group]}
{`${name} `}
{ssd && SSD}
RAM
Disk
{hasVms && (
vCPU
)}
$/hour
onRowClick(id)}>
{bytes(memory, { decimalPlaces: 0, unitSeparator: ' ' })}
{bytes(disk, { decimalPlaces: 0, unitSeparator: ' ' })}
{hasVms && (
{vcpus}
)}
{fourDecimals(price)}
);
export const Package = ({
selected = false,
id,
name,
group,
memory,
price,
vcpus,
disk,
ssd,
hasVms,
sortBy,
onRowClick
}) => (
onRowClick(id)}>
{GroupIcons[group]}
{name}
{bytes(memory, { decimalPlaces: 0, unitSeparator: ' ' })}
{bytes(disk, { decimalPlaces: 0, unitSeparator: ' ' })}
{ssd && SSD}
{hasVms && (
{vcpus}
)}
{fourDecimals(price)}
);
export const Packages = ({
pristine,
sortBy = 'name',
sortOrder = 'desc',
onSortBy = () => null,
hasVms,
children,
packages
}) => (
);
export const Overview = ({
name,
price,
memory,
vcpus,
hasVms,
ssd,
disk,
onCancel
}) => (
{name}
{price} $
{bytes(memory, { decimalPlaces: 0, unitSeparator: ' ' })}
{hasVms && (
{vcpus} vCPUS
)}
{bytes(disk, { decimalPlaces: 0, unitSeparator: ' ' })} disk
{ssd && SSD}
);
export const Empty = ({ children, ...rest }) => (
{children}
);