Skip to content

Commit

Permalink
Merge pull request #364 from eduzz/develop
Browse files Browse the repository at this point in the history
Versão 0.52.0
  • Loading branch information
ffernandomoraes authored Jul 11, 2022
2 parents 8a0943c + 8863b93 commit 4ec6da1
Show file tree
Hide file tree
Showing 24 changed files with 406 additions and 234 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@eduzz/houston-workspaces",
"version": "0.51.0",
"version": "0.52.0",
"workspaces": [
"src/pages/*",
"src/dev",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eduzz/houston-core",
"version": "0.51.0",
"version": "0.52.0",
"description": "Houston Core",
"main": "index.js",
"types": "./index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/eslint-config-houston",
"private": false,
"version": "0.51.0",
"version": "0.52.0",
"description": "Eduzz Houston Eslint Config",
"author": "Eduzz Team",
"license": "MIT",
Expand Down
10 changes: 5 additions & 5 deletions src/pages/experimental/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/houston-experimental",
"description": "Eduzz Houston Experimental",
"version": "0.51.0",
"version": "0.52.0",
"main": "./index.js",
"types": "./index.d.ts",
"author": "Eduzz Team",
Expand All @@ -16,9 +16,9 @@
"url": "https://github.com/eduzz/houston/issues"
},
"dependencies": {
"@eduzz/houston-ui": "0.51.0",
"@eduzz/houston-hooks": "0.51.0",
"@eduzz/houston-icons": "0.51.0",
"@eduzz/houston-ui": "0.52.0",
"@eduzz/houston-hooks": "0.52.0",
"@eduzz/houston-icons": "0.52.0",
"@emotion/css": "^11",
"@mui/material": "^5",
"@mui/styles": "^5",
Expand All @@ -27,6 +27,6 @@
"tslib": "^2"
},
"peerDependencies": {
"@eduzz/houston-core": "0.51.0"
"@eduzz/houston-core": "0.52.0"
}
}
8 changes: 4 additions & 4 deletions src/pages/forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eduzz/houston-forms",
"version": "0.51.0",
"version": "0.52.0",
"description": "Houston Forms",
"main": "index.js",
"types": "./index.d.ts",
Expand All @@ -16,15 +16,15 @@
"url": "https://github.com/eduzz/houston/issues"
},
"dependencies": {
"@eduzz/houston-core": "0.51.0",
"@eduzz/houston-hooks": "0.51.0",
"@eduzz/houston-core": "0.52.0",
"@eduzz/houston-hooks": "0.52.0",
"@types/yup": "^0.29",
"formik": "^2",
"rxjs": "^7",
"yup": "^0.32"
},
"peerDependencies": {
"@eduzz/houston-core": "0.51.0"
"@eduzz/houston-core": "0.52.0"
},
"devDependencies": {}
}
4 changes: 2 additions & 2 deletions src/pages/hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/houston-hooks",
"description": "Eduzz Houston Hooks",
"version": "0.51.0",
"version": "0.52.0",
"main": "./index.js",
"types": "./index.d.ts",
"author": "Eduzz Team",
Expand All @@ -16,7 +16,7 @@
"url": "https://github.com/eduzz/houston/issues"
},
"dependencies": {
"@eduzz/houston-core": "0.51.0",
"@eduzz/houston-core": "0.52.0",
"lodash": "^4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/icons/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/houston-icons",
"description": "Eduzz Houston Icons",
"version": "0.51.0",
"version": "0.52.0",
"main": "./index.js",
"types": "./index.d.ts",
"author": "Eduzz Team",
Expand Down
4 changes: 2 additions & 2 deletions src/pages/styles/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/houston-styles",
"description": "Eduzz Houston Style",
"version": "0.51.0",
"version": "0.52.0",
"main": "./index.js",
"types": "./index.d.ts",
"author": "Eduzz Team",
Expand All @@ -16,7 +16,7 @@
"url": "https://github.com/eduzz/houston/issues"
},
"dependencies": {
"@eduzz/houston-tokens": "0.51.0",
"@eduzz/houston-tokens": "0.52.0",
"@emotion/css": "^11",
"@emotion/react": "^11",
"@emotion/styled": "^11",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tokens/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/houston-tokens",
"description": "Eduzz Houston Tokens",
"version": "0.51.0",
"version": "0.52.0",
"main": "./index.js",
"types": "./index.d.ts",
"author": "Eduzz Team",
Expand Down
123 changes: 104 additions & 19 deletions src/pages/ui-components/Grid/Column/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,108 @@
import * as React from 'react';

import Grid, { GridProps } from '@mui/material/Grid';

type IOmitProps =
| 'container'
| 'item'
| 'justify'
| 'justifyContent'
| 'spacing'
| 'zeroMinWidth'
| 'alignContent'
| 'alignItems'
| 'direction'
| 'wrap';

export interface IColumnProps extends Omit<GridProps, IOmitProps> {}

const Column = React.forwardRef<HTMLDivElement, IColumnProps>(({ className, ...rest }, ref) => {
return <Grid {...rest} item className={className} ref={ref} />;
import styled, { css, cx, IStyledProp, IHoustonTheme } from '@eduzz/houston-styles';

import { useRow } from '../context';
import { Spacing } from '../Row';

type ColumnSize = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | true;
type BreakPoints = 'xs' | 'sm' | 'md' | 'lg' | 'xlg';
type Sizes = Partial<Record<BreakPoints, ColumnSize>>;

export type IColumn = IStyledProp &
Sizes & {
children: React.ReactNode;
};

const Column = React.forwardRef<HTMLDivElement, IColumn>(({ className, children, xs = true, sm, md, lg, xlg }, ref) => {
const { spacing = 'xxs' } = useRow();
return (
<div
ref={ref}
className={cx(
className,
`--spacing-${spacing}`,
xs && `--xs-${xs}`,
sm && `--sm-${sm}`,
md && `--md-${md}`,
lg && `--lg-${lg}`,
xlg && `--xlg-${xlg}`
)}
>
{children}
</div>
);
});

export default Column;
const COLUMNS = 12;
const NONE_IN_REM = '0rem';

const generateBreakAndWidth = (theme: IHoustonTheme, sizes: Sizes, spacing: Spacing) => {
return Object.entries(sizes)
.map(([breakpoint, size]: [BreakPoints, ColumnSize]) => {
if (typeof size === 'boolean') {
return `
&.--${breakpoint}-${size} {
${theme.breakpoints.up(breakpoint)} {
flex-grow: 1;
width: auto;
margin: calc(${theme.spacing.inline[spacing] ?? NONE_IN_REM} / 2);
}
}`;
}

return `
&.--${breakpoint}-${size} {
${theme.breakpoints.up(breakpoint)} {
width: calc(${((sizes[breakpoint] as number) / COLUMNS) * 100}% - ${
theme.spacing.inline[spacing] ?? NONE_IN_REM
});
margin: calc(${theme.spacing.inline[spacing] ?? NONE_IN_REM} / 2);
}
}`;
})
.join('');
};

export default React.memo(
styled(Column, { label: 'houston-grid-column' })(({ theme, xs = true, sm, md, lg, xlg }) => {
const sizes = {
...(xs && { xs }),
...(sm && { sm }),
...(md && { md }),
...(lg && { lg }),
...(xlg && { xlg })
};

return css`
&.--spacing-none {
${generateBreakAndWidth(theme, sizes, 'none')}
}
&.--spacing-nano {
${generateBreakAndWidth(theme, sizes, 'nano')}
}
&.--spacing-xxxs {
margin: calc(${theme.spacing.xxxs} / 2);
${generateBreakAndWidth(theme, sizes, 'xxxs')}
}
&.--spacing-xxs {
${generateBreakAndWidth(theme, sizes, 'xxs')}
}
&.--spacing-xs {
${generateBreakAndWidth(theme, sizes, 'xs')}
}
&.--spacing-md {
${generateBreakAndWidth(theme, sizes, 'md')}
}
&.--spacing-xl {
${generateBreakAndWidth(theme, sizes, 'xl')}
}
`;
})
);
102 changes: 30 additions & 72 deletions src/pages/ui-components/Grid/Container/index.tsx
Original file line number Diff line number Diff line change
@@ -1,77 +1,35 @@
import * as React from 'react';

import MUIContainer, { ContainerProps } from '@mui/material/Container';
import styled, { css, cx, IStyledProp } from '@eduzz/houston-styles';

import { cx } from '@eduzz/houston-styles';
import createUseStyles from '@eduzz/houston-styles/createUseStyles';

import GridContextProvider from '../context';
import { IContainerType } from '../interfaces';

const useStyles = createUseStyles({
root: {
width: '100%',
maxWidth: 1062,
margin: '0 auto'
},
comfortable: {
padding: '0 18px'
},
cozy: {
padding: '0 28px'
},
compact: {
padding: '0 20px'
},
fluid: {
maxWidth: '100%'
}
});

type ContainerPropsExtends = 'id' | 'className' | 'children' | 'style' | 'tabIndex';

export type IContainterLayout = 'fluid' | 'solid';

export interface IContainerProps extends Pick<ContainerProps, ContainerPropsExtends> {
/**
* Type container
*
* `comfortable` spacing big
* `cozy` spacing medium
* `compact` spacing small
*
* default `cozy`
*/
spacing?: IContainerType;
/**
* Types layout
*
* `fluid` max-width ignored
* `solid` limited
*
* default `solid`
*/
layout?: IContainterLayout;
export type IContainerLayout = 'fluid' | 'solid';
export interface IContainer extends IStyledProp {
children: React.ReactNode;
layout?: IContainerLayout;
}

const Container = React.forwardRef<HTMLDivElement, IContainerProps>(
({ children, className, spacing = 'cozy', layout = 'solid', ...rest }, ref) => {
const classes = useStyles();

const contextValue = React.useMemo(() => ({ spacing }), [spacing]);

return (
<GridContextProvider value={contextValue}>
<MUIContainer
{...rest}
ref={ref}
className={cx(classes.root, classes[spacing], layout === 'fluid' && classes.fluid, className)}
>
{children}
</MUIContainer>
</GridContextProvider>
);
}
);

export default React.memo(Container);
const Container = React.forwardRef<HTMLDivElement, IContainer>(({ className, children, layout }, ref) => (
<div ref={ref} className={cx(className, `--${layout ?? 'solid'}`)}>
{children}
</div>
));

export default React.memo(styled(Container, { label: 'houston-grid-container' })`
${({ theme }) => {
const MAX_WIDTH_IN_PX = theme.breakpoints.xlg;
return css`
width: 100%;
max-width: ${MAX_WIDTH_IN_PX};
margin: 0 auto;
padding: 0 ${theme.spacing.xs};
${theme.breakpoints.down('sm')} {
padding: 0 ${theme.spacing.xxxs};
}
&.--fluid {
max-width: 100%;
}
`;
}}
`);
Loading

0 comments on commit 4ec6da1

Please sign in to comment.