0.6.0 β€’ Published 7 months ago

amethyst-layout v0.6.0

Weekly downloads
-
License
-
Repository
github
Last release
7 months ago

How to install πŸ› 

Open your terminal, navigate to your project, and enter the following command.

npm install amethyst-layout

How to use ✨

You can see the description and example components in our Storybook page.

Samples πŸ“¦

Container

Container component is designed to center-align its inner elements, making it particularly useful when placing text content inside this component.

import { Container } from 'amethyst-layout';

const App = () => {
  return (
    <Container maxWidth={720} verticalPadding={30} horizontalPadding={10}>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus nec
      vulputate arcu, nec semper est.
    </Container>
  );
};

export default App;

Flex

Flex component is designed for effortless flex element implementation, typically used in complex and responsive layouts. We recommend using Grid if you want to use fixed layouts.

import { Container } from 'amethyst-layout';

const App = () => {
  return (
    <Flex gap={5} justify="center" align="center" wrap="wrap">
      <Item /> {/* Your item components */}
      <Item />
      <Item />
      <Item />
      {/* ...more items */}
    </Flex>
  );
};

export default App;

Grid

Grid component is designed for effortless grid element implementation, typically used in fixed layouts.

import { Grid } from 'amethyst-layout';

const App = () => {
  return (
    <Grid rows={3} columns={4} gap={5}>
      <Item /> {/* Your item components */}
      <Item />
      <Item />
      <Item />
      {/* ...more items */}
    </Grid>
  );
};

export default App;

SplitPane

SplitPane component is a component that allows users to adjust the sizes of two or more child components. Use the resize bar to change these sizes. SplitPane μ»΄ν¬λ„ŒνŠΈλŠ” 두 개 μ΄μƒμ˜ μžμ‹ μ»΄ν¬λ„ŒνŠΈλ₯Ό μ‚¬μš©μžκ°€ 자유둜이 μ‘°μ ˆν•  수 μžˆλŠ” μ»΄ν¬λ„ŒνŠΈμž…λ‹ˆλ‹€.

Properties

If the property is optional, a ? will be appended after the name.
속성이 ν•„μˆ˜κ°’μ΄ μ•„λ‹Œ 경우 이름 뒀에 ? κ°€ λΆ™μŠ΅λ‹ˆλ‹€. | Name | Type | Description | Default | |:-:|:-:|---|:-:| |defaultRatios|number[]|Ratios of the child on first render. The unit of the ratio is %. Note that sum of the ratios must be 100, and the length of the number array must same with children count. otherwise it will not work as you expected.처음으둜 μžμ‹ μš”μ†Œλ“€μ„ λžœλ”λ§ν•  λ•Œ 각 μžμ‹ μš”μ†Œκ°€ μ°¨μ§€ν•˜κ²Œ 될 λΉ„μœ¨μž…λ‹ˆλ‹€. λΉ„μœ¨μ˜ λ‹¨μœ„λŠ” %μž…λ‹ˆλ‹€. λ°˜λ“œμ‹œ λΉ„μœ¨μ˜ 합은 100이 λ˜μ–΄μ•Ό ν•˜λ©°, λΉ„μœ¨μ˜ κ°’μ˜ κ°œμˆ˜λŠ” μžμ‹ μš”μ†Œμ˜ κ°œμˆ˜μ™€ μΌμΉ˜ν•΄μ•Ό ν•©λ‹ˆλ‹€. 그렇지 μ•Šμ„ 경우 μ»΄ν¬λ„ŒνŠΈκ°€ μ˜€μž‘λ™ν•  수 μžˆμŠ΅λ‹ˆλ‹€.|-| |direction?|'row' \| 'column'|Alignment direction of children.μžμ‹ μ»΄ν¬λ„ŒνŠΈλ“€μ΄ λ°°μΉ˜λ˜λŠ” λ°©ν–₯μž…λ‹ˆλ‹€.|row| |resizerThickness?|number| Thickness of the resizers for resizing child components. You can use only number type, which means the pixels of thickness.μžμ‹ μ»΄ν¬λ„ŒνŠΈμ˜ 크기λ₯Ό μ‘°μ ˆν•  수 μžˆλŠ” μ†μž‘μ΄μ˜ κ΅΅κΈ°μž…λ‹ˆλ‹€. px λ‹¨μœ„λ§Œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.|15| |borderThickness?|number|Thickness of the border of the component. You can use only number type, which means the pixels of thickness.μœ€κ³½μ„ μ˜ κ΅΅κΈ°μž…λ‹ˆλ‹€. px λ‹¨μœ„λ§Œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.|2| |minimumRatio?|number|The minimum ratio of the child components. Child components will not shrink below this value.각 μžμ‹ μ»΄ν¬λ„ŒνŠΈκ°€ κ°€μ§€κ²Œ 될 μ΅œμ†Œ 크기(λΉ„μœ¨)μž…λ‹ˆλ‹€. μ†μž‘μ΄λ₯Ό μ‘°μ ˆν•˜λ”λΌλ„ μ΅œμ†Œ 크기 λ―Έλ§ŒμœΌλ‘œλŠ” 쀄어듀지 μ•ŠμŠ΅λ‹ˆλ‹€.|0| |maximumRatio?|number|The maximum ratio of the child components. Child components will not expand above this value.각 μžμ‹ μ»΄ν¬λ„ŒνŠΈκ°€ κ°€μ§€κ²Œ 될 μ΅œλŒ€ 크기(λΉ„μœ¨)μž…λ‹ˆλ‹€. μ†μž‘μ΄λ₯Ό μ‘°μ ˆν•˜λ”λΌλ„ μ΅œλŒ€ 크기보닀 λŠ˜μ–΄λ‚˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.|100| horizontalMargin?|${number}px \| ${number}% \| number|The margins for the left and right sides. Useful when you want to align multiple SplitPane components in a horizontal arrangement. You can use the unit of %, px, or numeric values.μ»΄ν¬λ„ŒνŠΈμ˜ 쒌우 margin을 μ˜λ―Έν•©λ‹ˆλ‹€. μ—¬λŸ¬ 개의 SplitPane μ»΄ν¬λ„ŒνŠΈλ₯Ό κ°€λ‘œλ‘œ λ°°μΉ˜ν•  λ•Œ 특히 μœ μš©ν•©λ‹ˆλ‹€. %, px λ‹¨μœ„μ˜ 값을 μ‚¬μš©ν•˜κ±°λ‚˜ μ •μˆ˜ 값을 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.|0| verticalMargin?|${number}px \| ${number}% \| number|The margins for the top and bottom sides. Useful when you want to align multiple SplitPane components in a vertical arrangement. You can use the unit of %, px, or numeric values.μ»΄ν¬λ„ŒνŠΈμ˜ μƒν•˜ margin을 μ˜λ―Έν•©λ‹ˆλ‹€. μ—¬λŸ¬ 개의 SplitPane μ»΄ν¬λ„ŒνŠΈλ₯Ό μ„Έλ‘œλ‘œ λ°°μΉ˜ν•  λ•Œ 특히 μœ μš©ν•©λ‹ˆλ‹€. %, px λ‹¨μœ„μ˜ 값을 μ‚¬μš©ν•˜κ±°λ‚˜ μ •μˆ˜ 값을 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.|0| width?|${number}px \| ${number}% \| number|The width of the component. You can use the unit of %, px, or numeric values.μ»΄ν¬λ„ŒνŠΈμ˜ κ°€λ‘œ κΈΈμ΄μž…λ‹ˆλ‹€. %, px λ‹¨μœ„μ˜ 값을 μ‚¬μš©ν•˜κ±°λ‚˜ μ •μˆ˜ 값을 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.|100%| height?|${number}px \| ${number}% \| number|The height of the component. You can use the unit of %, px, or numeric values.μ»΄ν¬λ„ŒνŠΈμ˜ μ„Έλ‘œ κΈΈμ΄μž…λ‹ˆλ‹€. %, px λ‹¨μœ„μ˜ 값을 μ‚¬μš©ν•˜κ±°λ‚˜ μ •μˆ˜ 값을 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.|100%| themeColor?|$#{string}|The theme color of the component. While the SplitPanecomponent doesn't directly provide color-related properties, you can use the theme color to define the overall design of the component. If you specify the theme color, the appropriate design will be automatically applied. You can use Hex format to apply theme using a color.μ»΄ν¬λ„ŒνŠΈμ˜ ν…Œλ§ˆ μƒ‰μž…λ‹ˆλ‹€.SplitPaneμ»΄ν¬λ„ŒνŠΈλŠ”color κ΄€λ ¨ ν”„λ‘œνΌν‹°λ₯Ό μ§μ ‘μ μœΌλ‘œ μ œκ³΅ν•˜μ§€λŠ” μ•Šμ§€λ§Œ, ν…Œλ§ˆ 색을 μ΄μš©ν•˜μ—¬ μ»΄ν¬λ„ŒνŠΈμ˜ 전체적인 λ””μžμΈμ„ μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€. ν…Œλ§ˆ μƒ‰λ§Œ μ—¬λŸ¬λΆ„μ΄ μ •ν•΄μ£Όμ‹ λ‹€λ©΄ 그에 κ±Έλ§žλŠ” λ””μžμΈμ΄ μ•Œμ•„μ„œ μ μš©λ©λ‹ˆλ‹€. Hex λ‹¨μœ„μ˜ 값을 μ‚¬μš©ν•΄ μ£Όμ„Έμš”.|#be33ff|

Examples

<Item /> component is not included in this library, use your own children.
<Item /> μ»΄ν¬λ„ŒνŠΈλŠ” 이 λΌμ΄λΈŒλŸ¬λ¦¬μ— ν¬ν•¨λ˜μ–΄ μžˆμ§€ μ•ŠμŠ΅λ‹ˆλ‹€. μ—¬λŸ¬λΆ„μ˜ μš©λ„μ— 맞게 이 μžλ¦¬μ— μ—¬λŸ¬λΆ„μ˜ μžμ‹ μ»΄ν¬λ„ŒνŠΈλ₯Ό μ‚¬μš©ν•΄ μ£Όμ„Έμš”.

  • A Simple way to use the SplitPane component
  • κ°€μž₯ κ°„λ‹¨ν•œ λ°©μ‹μ˜ SplitPane μ»΄ν¬λ„ŒνŠΈ μ‚¬μš© 방법 μ˜ˆμ‹œμž…λ‹ˆλ‹€.
import { SplitPane } from 'amethyst-layout';
import { Item } from 'your-awesome-component';

const App = () => {
  return (
    <SplitPane defaultRatios={[50, 50]}>
      <Item />
      <Item />
    </SplitPane>
  );
};

export default App;
  • SplitPane component with various props
  • λ‹€μ–‘ν•œ propsκ°€ ν¬ν•¨λ˜μ–΄ μžˆλŠ” SplitPane μ»΄ν¬λ„ŒνŠΈ μ˜ˆμ‹œμž…λ‹ˆλ‹€.
import { SplitPane } from 'amethyst-layout';
import { Item } from 'your-awesome-component';

const App = () => {
  return (
    <SplitPane
      defaultRatios={[20, 30, 50]}
      direction="column"
      resizerThickness={30}
      borderThickness={4}
      minimumRatio={10}
      maximumRatio={90}
      horizontalMargin={5}
      verticalMargin={20}
      width={400}
      height={300}
      themeColor="#0004ff"
    >
      <Item />
      <Item />
      <Item />
    </SplitPane>
  );
};

export default App;
  • Nested SplitPane components
  • μ€‘μ²©λœ SplitPane μ»΄ν¬λ„ŒνŠΈμ˜ μ‚¬μš©λ„ κ°€λŠ₯ν•©λ‹ˆλ‹€. 이λ₯Ό ν™œμš©ν•΄ 더 λ³΅μž‘ν•œ λ ˆμ΄μ•„μ›ƒμ„ λ§Œλ“€ 수 μžˆμŠ΅λ‹ˆλ‹€.
import { SplitPane } from 'amethyst-layout';
import { Item } from 'your-awesome-component';

const App = () => {
  return (
    <SplitPane defaultRatios={[30, 70]}>
      <Item />
      <SplitPane defaultRatios={[50, 50]} direction="column">
        <Item />
        <Item />
      </SplitPane>
    </SplitPane>
  );
};