Skip to content

Minor flex fixes #84

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

Merged
merged 11 commits into from
May 29, 2021
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
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"dependencies": {
"@emotion/css": "^11.1.3",
"@emotion/react": "^11.1.5",
"@emotion/react": "^11.4.0",
"color": "^3.1.3",
"csstips": "^1.2.0",
"debounce": "^1.2.0",
Expand All @@ -41,13 +41,13 @@
"@babel/preset-react": "^7.10.4",
"@emotion/eslint-plugin": "^11.2.0",
"@sambego/storybook-state": "^2.0.1",
"@storybook/addon-actions": "^6.1.11",
"@storybook/addon-actions": "^6.2.9",
"@storybook/addon-contexts": "^5.3.21",
"@storybook/addon-essentials": "^6.1.11",
"@storybook/addon-essentials": "^6.2.9",
"@storybook/addon-info": "^5.3.21",
"@storybook/addon-links": "^6.1.11",
"@storybook/cli": "^6.1.11",
"@storybook/react": "^6.1.11",
"@storybook/addon-links": "^6.2.9",
"@storybook/cli": "^6.2.9",
"@storybook/react": "^6.2.9",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.3",
"@types/color": "^3.0.1",
Expand All @@ -71,13 +71,12 @@
"lint-staged": "^10.2.13",
"prettier": "^2.0.5",
"react": "^17.0.2",
"react-docgen-typescript-loader": "^3.7.2",
"react-dom": "^17.0.2",
"react-icons": "^4.2.0",
"source-map-loader": "^1.0.2",
"stylelint": "^13.6.1",
"ts-jest": "^26.3.0",
"typescript": "^4.2.4"
"typescript": "4.2.4"
},
"browserslist": [
"last 2 versions",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AutoComplete/AutoComplete.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const AsyncFetch: Story = () => {
}
uniqueIdentifier={(e) => String(e.id)}
listDisplayProp={(e) => (
<Row gutter={[0, 20]}>
<Row gutter={[0, 50]}>
<Col flex="0 1 50px">
<img width="100%" src={e.avatar} />
</Col>
Expand Down
5 changes: 3 additions & 2 deletions src/components/AutoComplete/AutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class AutoComplete<T> extends React.Component<AutoCompleteProps<T>, State
<Skeleton
isLoading={loading}
render={() => (
<List densed style={{ maxHeight: '300px', overflowY: 'auto' }}>
<List elevation={0} padding={0} densed style={{ maxHeight: '300px', overflowY: 'auto' }}>
{filteredData?.map((v, i) => (
<ListItem
key={uniqueIdentifier(v)}
Expand Down Expand Up @@ -250,13 +250,14 @@ export class AutoComplete<T> extends React.Component<AutoCompleteProps<T>, State

return (
<Popover
trigger={['onClick', 'onFocus']}
trigger={['onClick']}
position="bottom"
content={this.displayList()}
onVisibleChange={(v) => this.onOpen(v)}
visible={open}
expand
hideArrow
padding={0}
style={{ child: { display: 'block' } }}
>
<div>{inputElem}</div>
Expand Down
94 changes: 46 additions & 48 deletions src/components/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { nestedAccess } from './../../helpers';
import { Row, Col } from './../../index';
import { Card, CardBody } from '../Card';
import { Card } from '../Card';
import Color from 'color';
import { Button } from '../Button';
import { Tooltip } from '../Tooltip';
Expand Down Expand Up @@ -189,54 +189,52 @@ export const Calendar: React.FC<CalendarProps> = (props) => {

return (
<Card elevation={props.elevation} padding={props.padding} margin={props.margin} border={props.border}>
<CardBody>
<Row gutter={[10, 10]} justifyContent="flex-end">
<Col flex="0 1 auto">
<Menu
height="300px"
trigger="onClick"
anchor={
<Button primary displayBlock flat>
{months[date.getMonth()]}
</Button>
}
>
{months.map((v) => (
<MenuItem active={v === months[date.getMonth()]} onClick={() => monthChange(v)} key={v}>
{v}
</MenuItem>
))}
</Menu>
</Col>
<Col flex="0 1 auto">
<Menu
height="300px"
trigger="onClick"
anchor={
<Button primary displayBlock flat>
{date.getFullYear()}
</Button>
}
>
{arrayBetween(1980, 2030).map((v) => (
<MenuItem active={v === date.getFullYear()} onClick={() => yearChange(v)} key={v}>
{v}
</MenuItem>
))}
</Menu>
<Row gutter={[10, 10]} justifyContent="flex-end">
<Col flex="0 1 auto">
<Menu
height="300px"
trigger="onClick"
anchor={
<Button primary displayBlock flat>
{months[date.getMonth()]}
</Button>
}
>
{months.map((v) => (
<MenuItem active={v === months[date.getMonth()]} onClick={() => monthChange(v)} key={v}>
{v}
</MenuItem>
))}
</Menu>
</Col>
<Col flex="0 1 auto">
<Menu
height="300px"
trigger="onClick"
anchor={
<Button primary displayBlock flat>
{date.getFullYear()}
</Button>
}
>
{arrayBetween(1980, 2030).map((v) => (
<MenuItem active={v === date.getFullYear()} onClick={() => yearChange(v)} key={v}>
{v}
</MenuItem>
))}
</Menu>
</Col>
</Row>
<Row>
{weeks.map((v) => (
<Col span={24 / 7} key={v}>
<Text fontWeight={600} textAlign="center" variant="p" color="light">
{v.slice(0, 3)}
</Text>
</Col>
</Row>
<Row>
{weeks.map((v) => (
<Col span={24 / 7} key={v}>
<Text fontWeight={600} textAlign="center" variant="p" color="light">
{v.slice(0, 3)}
</Text>
</Col>
))}
</Row>
<Row>{getdateArray()}</Row>
</CardBody>
))}
</Row>
<Row>{getdateArray()}</Row>
</Card>
);
};
Expand Down
20 changes: 8 additions & 12 deletions src/components/Card/Card.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import { Story, Meta } from '@storybook/react';

import { Card, CardHeader, CardBody, CardMedia, Button } from '../..';
import { Card, CardHeader, CardMedia, Button } from '../..';
import { IoMdOptions } from 'react-icons/io';
import { CardProps } from './Card';

export default {
title: 'Display/Card',
component: Card,
subcomponents: { CardHeader, CardBody, CardMedia },
subcomponents: { CardHeader, CardMedia },
argTypes: {
// backgroundColor: { control: 'color' },
},
Expand All @@ -21,11 +21,9 @@ HeaderAndBody.args = {
children: (
<>
<CardHeader subtitle="Do you Know Lorem Ipsum?">Lorem Ipsum</CardHeader>
<CardBody>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the standard
dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type
specimen book.
</CardBody>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the standard dummy
text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen
book.
</>
),
};
Expand All @@ -38,11 +36,9 @@ CardMediaAndBody.args = {
<CardHeader subtitle="Do you Know Lorem Ipsum?" action={<Button flat icon={<IoMdOptions />} />}>
Lorem Ipsum
</CardHeader>
<CardBody>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the standard
dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type
specimen book.
</CardBody>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the standard dummy
text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen
book.
</>
),
};
8 changes: 0 additions & 8 deletions src/components/Card/CardBody.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Card/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { Card } from './Card';
export { CardHeader } from './CardHeader';
export { CardBody } from './CardBody';
export { CardMedia } from './CardMedia';
3 changes: 2 additions & 1 deletion src/components/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const DatePicker: React.FC<DatePickerProps> = (props) => {
return (
<>
<Popover
padding={0}
content={
<Row>
<Col span={24}>
Expand Down Expand Up @@ -64,7 +65,7 @@ export const DatePicker: React.FC<DatePickerProps> = (props) => {
onVisibleChange={updateVisible}
style={{ child: { display: 'block' }, content: { width: '400px' } }}
hideArrow
trigger={['onClick', 'onFocus']}
trigger={['onClick']}
>
<Input
{...rest}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Input/BaseInputComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const BaseInputComponent = React.forwardRef<
{before}
</Col>
)}
<Col flex="1" style={{ width: '0', overflow: 'hidden' }}>
<Col flex="1" style={{ overflow: 'hidden' }}>
{React.cloneElement(children, {
className: css.input,
required,
Expand Down
2 changes: 1 addition & 1 deletion src/components/List/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const ListItem: React.FC<ListItemProps> = (props) => {
} = props;

const theme = useTheme();
const css = listStyle(theme.background);
const css = listStyle(theme.background, !!onClick);

const Element: React.FC<unknown> = (p) =>
React.cloneElement(element || <li />, {
Expand Down
4 changes: 2 additions & 2 deletions src/components/List/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export const list = (background: string, border: number, theme: Theme) =>
},
});

export const listItem = (background: string) =>
export const listItem = (background: string, clickable: boolean) =>
css({
transition: 'background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
cursor: 'pointer',
cursor: clickable && 'pointer',
listStyle: 'none',
overflow: 'hidden',
padding: '6px 8px 6px 9px',
Expand Down
63 changes: 31 additions & 32 deletions src/components/Loading/Skeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import { Card, CardBody } from '../Card';
import { Card } from '../Card';
import { skeletonStyle as style } from './style';
import { useTheme } from '../Theme/Theme';
import { SurfaceProps } from '../../typings/surface';

export const Skeleton: React.FunctionComponent<SkeletonProps> = (props) => {
const { isLoading, render = () => <div /> } = props;
Expand All @@ -10,47 +11,45 @@ export const Skeleton: React.FunctionComponent<SkeletonProps> = (props) => {
const theme = useTheme();

return (
<Card>
<CardBody>
<div className={style(theme)}>
<div className="skeleton">
<div className="skeleton-content">
<div className="skeleton-header">
<div className="skeleton-line" style={{ width: '60%' }} />
</div>
<div className="skeleton-text">
<div className="skeleton-line" style={{ width: '90%' }} />
<div className="skeleton-line" style={{ width: '100%' }} />
<div className="skeleton-line" style={{ width: '35%' }} />
</div>
<div className="skeleton-header">
<div className="skeleton-line" style={{ width: '60%' }} />
</div>
<div className="skeleton-text">
<div className="skeleton-line" style={{ width: '90%' }} />
<div className="skeleton-line" style={{ width: '100%' }} />
<div className="skeleton-line" style={{ width: '35%' }} />
</div>
<div className="skeleton-header">
<div className="skeleton-line" style={{ width: '60%' }} />
</div>
<div className="skeleton-text">
<div className="skeleton-line" style={{ width: '90%' }} />
<div className="skeleton-line" style={{ width: '100%' }} />
<div className="skeleton-line" style={{ width: '35%' }} />
</div>
<Card elevation={props.elevation} border={props.border} padding={props.padding} margin={props.margin}>
<div className={style(theme)}>
<div className="skeleton">
<div className="skeleton-content">
<div className="skeleton-header">
<div className="skeleton-line" style={{ width: '60%' }} />
</div>
<div className="skeleton-text">
<div className="skeleton-line" style={{ width: '90%' }} />
<div className="skeleton-line" style={{ width: '100%' }} />
<div className="skeleton-line" style={{ width: '35%' }} />
</div>
<div className="skeleton-header">
<div className="skeleton-line" style={{ width: '60%' }} />
</div>
<div className="skeleton-text">
<div className="skeleton-line" style={{ width: '90%' }} />
<div className="skeleton-line" style={{ width: '100%' }} />
<div className="skeleton-line" style={{ width: '35%' }} />
</div>
<div className="skeleton-header">
<div className="skeleton-line" style={{ width: '60%' }} />
</div>
<div className="skeleton-text">
<div className="skeleton-line" style={{ width: '90%' }} />
<div className="skeleton-line" style={{ width: '100%' }} />
<div className="skeleton-line" style={{ width: '35%' }} />
</div>
</div>
</div>
</CardBody>
</div>
</Card>
);
}

return render && render();
};

export interface SkeletonProps {
export interface SkeletonProps extends SurfaceProps {
isLoading?: boolean;
render?: () => React.ReactElement;
}
Loading