Skip to content

Commit

Permalink
🚚 chore: rename package
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Nov 28, 2021
1 parent 575be7a commit fa558eb
Show file tree
Hide file tree
Showing 20 changed files with 249 additions and 105 deletions.
2 changes: 1 addition & 1 deletion config/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const menus = {
},
{
title: 'LayoutToolkit 布局工具库',
children: ['layout-toolkit'],
children: ['layout-kit'],
},
],
'/guide': [
Expand Down
2 changes: 1 addition & 1 deletion jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
'@arvinxu/heatmap-calendar': '<rootDir>/packages/heatmap-calendar/src',
'@arvinxu/utils': '<rootDir>/packages/utils/src',
'@arvinxu/i18n': '<rootDir>/packages/i18n/src',
'@arvinxu/layout-toolkit': '<rootDir>/packages/layout-toolkit/src',
'@arvinxu/layout-kit': '<rootDir>/packages/layout-kit/src',
'@arvinxu/float-label-input': '<rootDir>/packages/float-label-input/src',
'@arvinxu/page-loading': '<rootDir>/packages/page-loading/src',
'@arvinxu/mindflow': '<rootDir>/packages/mindflow/src',
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions packages/layout-kit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# @arvinxu/layout-kit

[![NPM version][version-image]][version-url] [![NPM downloads][download-image]][download-url]

## License

[MIT](../../LICENSE) ® Arvin Xu

<!-- npm url -->

[version-image]: http://img.shields.io/npm/v/@arvinxu/layout-kit.svg?color=deepgreen&label=latest
[version-url]: http://npmjs.org/package/@arvinxu/layout-kit
[download-image]: https://img.shields.io/npm/dm/@arvinxu/layout-kit.svg
[download-url]: https://npmjs.org/package/@arvinxu/layout-kit
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const base = require('../../jest.config.base');

const packageName = '@arvinxu/layout-toolkit';
const packageName = '@arvinxu/layout-kit';

const root = '<rootDir>/packages/layout-toolkit';
const root = '<rootDir>/packages/layout-kit';

module.exports = {
...base,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
{
"name": "@arvinxu/layout-toolkit",
"name": "@arvinxu/layout-kit",
"version": "1.0.0",
"files": [
"lib",
"es"
],
"main": "lib/index.js",
"module": "es/index.js",
"homepage": "https://github.com/arvinxx/components/tree/master/packages/layout-toolkit#readme",
"homepage": "https://github.com/arvinxx/components/tree/master/packages/layout-kit#readme",
"repository": "git+https://github.com/arvinxx/components.git",
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
},
"peerDependencies": {
"styled-components": ">5"
},
"devDependencies": {
"styled-components": "^5.3.3",
"@types/styled-components": "^5.1.15"
},
"scripts": {
"build": "father-build && yarn webpack",
"webpack": "webpack",
Expand Down
46 changes: 46 additions & 0 deletions packages/layout-kit/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type { DetailedHTMLProps, FC, HTMLAttributes } from 'react';
import styled from 'styled-components';

import { calcValue, getFlexDirection } from './utils';
import type {
ContentDistribution,
ContentPosition,
FlexDirection,
} from './type';

type CommonSpaceNumber = 2 | 4 | 8 | 12 | 16 | 24;

interface IFlexbox {
direction?: FlexDirection;
distribution?: ContentDistribution;
align?: ContentPosition;
gap?: CommonSpaceNumber | number;
width?: number | string;
height?: number | string;
padding?: string | number | CommonSpaceNumber;
}
export type FlexboxProps = IFlexbox &
DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;

export const Flexbox: FC<FlexboxProps> = styled.div.attrs(() => ({
className: 'layoutkit-flexbox',
}))<IFlexbox>`
display: flex;
flex-direction: ${(props) => {
return getFlexDirection(props.direction);
}};
justify-content: ${(props) => props.distribution};
align-items: ${(props) => props.align};
width: ${(props) => calcValue(props.width)};
height: ${(props) => calcValue(props.height)};
padding: ${(props) => calcValue(props.padding)};
> *:not(:last-child) {
margin-right: ${(props) =>
getFlexDirection(props.direction) === 'row' && calcValue(props.gap)};
margin-bottom: ${(props) =>
getFlexDirection(props.direction) === 'column' && calcValue(props.gap)};
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ nav:

<!-- npm url -->

[version-image]: http://img.shields.io/npm/v/@arvinxu/layout-toolkit.svg?color=deepgreen&label=latest
[version-url]: http://npmjs.org/package/@arvinxu/layout-toolkit
[download-image]: https://img.shields.io/npm/dm/@arvinxu/layout-toolkit.svg
[download-url]: https://npmjs.org/package/@arvinxu/layout-toolkit
[version-image]: http://img.shields.io/npm/v/@arvinxu/layout-kit.svg?color=deepgreen&label=latest
[version-url]: http://npmjs.org/package/@arvinxu/layout-kit
[download-image]: https://img.shields.io/npm/dm/@arvinxu/layout-kit.svg
[download-url]: https://npmjs.org/package/@arvinxu/layout-kit

<API src='./index.tsx'></API>
20 changes: 20 additions & 0 deletions packages/layout-kit/src/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export type ContentPosition =
| 'center'
| 'end'
| 'flex-end'
| 'flex-start'
| 'start'
| 'stretch';

export type ContentDistribution =
| 'center'
| 'space-around'
| 'space-between'
| 'space-evenly'
| 'stretch';

export type FlexDirection =
| 'vertical'
| 'vertical-reverse'
| 'horizontal'
| 'horizontal-reverse';
18 changes: 18 additions & 0 deletions packages/layout-kit/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { FlexDirection } from './type';

export const getFlexDirection = (direction: FlexDirection) => {
switch (direction) {
case 'horizontal':
return 'row';
case 'horizontal-reverse':
return 'row-reverse';
case 'vertical':
default:
return 'column';
case 'vertical-reverse':
return 'column-reverse';
}
};

export const calcValue = (value: string | number) =>
typeof value === 'number' ? `${value}px` : value;
16 changes: 16 additions & 0 deletions packages/layout-kit/tests/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Flexbox gap 1`] = `
<div>
<div
class="sc-bdvvtL ezjxOX"
>
<div>
1
</div>
<div>
2
</div>
</div>
</div>
`;
16 changes: 16 additions & 0 deletions packages/layout-kit/tests/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { render } from '@testing-library/react';

import { Flexbox } from '@arvinxu/layout-kit';

describe('Flexbox', () => {
it('gap', () => {
const { container } = render(
<Flexbox gap={2}>
<div>1</div>
<div>2</div>
</Flexbox>,
);
expect(container).toMatchSnapshot();
});
});
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
...config,
output: {
...config.output,
library: 'LayoutToolkit',
library: 'LayoutKit',
path: path.resolve(__dirname, 'dist'),
},
};
14 changes: 0 additions & 14 deletions packages/layout-toolkit/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions packages/layout-toolkit/src/index.tsx

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions packages/layout-toolkit/tests/index.test.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"@arvinxu/utils/*": ["./packages/utils/src/*"],
"@arvinxu/i18n": ["./packages/i18n/src"],
"@arvinxu/i18n/*": ["./packages/i18n/src/*"],
"@arvinxu/layout-toolkit": ["./packages/layout-toolkit/src"],
"@arvinxu/layout-toolkit/*": ["./packages/layout-toolkit/src/*"],
"@arvinxu/layout-kit": ["./packages/layout-kit/src"],
"@arvinxu/layout-kit/*": ["./packages/layout-kit/src/*"],
"@arvinxu/float-label-input": ["./packages/float-label-input/src"],
"@arvinxu/page-loading": ["./packages/page-loading/src"],
"@arvinxu/mindflow": ["./packages/mindflow/src"],
Expand Down
Loading

0 comments on commit fa558eb

Please sign in to comment.