Skip to content

Commit

Permalink
v2.5.0
Browse files Browse the repository at this point in the history
v2.5.0
  • Loading branch information
ssi02014 authored Feb 25, 2023
2 parents b7fb5ea + e04cc91 commit 77ebdd8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 33 deletions.
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,22 @@ const App = () => {
// If you do not enter this option, it will be rendered in the "root" div
// However, there is a possibility that the UI will change due to CSS inheritance

iconSrc={iconImage}
// Insert the icon of the button to open the Thumbnail Model.
buttonIcon={<img src={iconImage} width={30} height={30} />}
// Insert the inner icon of the button that opens the thumbnail modal using the "<img>" tag
// I recommend the 1:1 ratio icon.
// If you do not insert this option, the default icon takes effect.

iconSize="medium"
// Select the size of the default buttonIcon.
// If you do not enter this option, the default size(medium) applies
// But if you insert the button icon yourself, the option is meaningless.

iconPosition={[0, 20, 20, 0]}
// Select the location of the button to open the Thumbnail Model.
// Sequence: [top, right, bottom, left]

modalPosition='right'
// Select the location to open ThumbnailModal.

iconSize="medium"
// You can select the size of the button that opens the modal.
// If you do not enter this option, the default size(medium) applies

additionalFontFamily={['Noto Sans', ...]}
// You can add the font you want. But those fonts should already be applied to your project.
Expand Down Expand Up @@ -164,6 +166,7 @@ export default function Document() {

```jsx
import dynamic from "next/dynamic";
import Image from "next/image";

const ThumbnailGenerator = dynamic(() => import("react-thumbnail-generator"), {
ssr: false,
Expand All @@ -172,7 +175,10 @@ const ThumbnailGenerator = dynamic(() => import("react-thumbnail-generator"), {
export default function Home() {
return (
<>
<ThumbnailGenerator id="thumbnail-generator" />
<ThumbnailGenerator
id="thumbnail-generator"
buttonIcon={<Image src={profilePic} width={30} height={30} alt="buttonIcon" />}
/>
</>
);
}
Expand Down Expand Up @@ -253,13 +259,10 @@ const App = () => {
- id
- **Optional**
- Type: `string`
- iconSrc
- buttonIcon
- **Optional**
- Default

<img width="43" alt="스크린샷 2023-02-20 오후 10 48 05" src="https://user-images.githubusercontent.com/64779472/220125380-77aaaa79-9baf-4252-aa46-a44e6e91dd3d.png">

- Type: `string`
- Default: <img width="43" alt="스크린샷 2023-02-20 오후 10 48 05" src="https://user-images.githubusercontent.com/64779472/220125380-77aaaa79-9baf-4252-aa46-a44e6e91dd3d.png">
- Type: `Node`
- iconPosition
- **Optional**
- Sequence: [top, right, bottom, left]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-thumbnail-generator",
"version": "2.4.2",
"version": "2.5.0",
"description": "react-thumbnail-generator",
"main": "dist/index.js",
"module": "dist/index.js",
Expand Down
10 changes: 2 additions & 8 deletions src/components/Icon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import React from 'react';
import React, { ComponentProps } from 'react';

interface IconProps {
src: string;
width: number;
height: number;
}

const Icon = ({ src, width, height }: IconProps) => {
const Icon = ({ src, width, height }: ComponentProps<'img'>) => {
return <img src={src} width={width} height={height} />;
};

Expand Down
10 changes: 7 additions & 3 deletions src/lib/ThumbnailGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Icon from '../components/Icon';

interface ThumbnailGeneratorProps {
id?: string;
iconSrc?: string;
buttonIcon?: React.ReactNode;
iconSize?: 'small' | 'medium' | 'large';
position?: Position;
iconPosition?: [number, number, number, number];
Expand All @@ -18,7 +18,7 @@ interface ThumbnailGeneratorProps {

const ThumbnailGenerator = ({
id,
iconSrc = toggleButton,
buttonIcon,
iconSize = 'medium',
iconPosition = [0, 20, 20, 0],
modalPosition = 'right',
Expand All @@ -42,7 +42,11 @@ const ThumbnailGenerator = ({
/>
) : (
<TGOpenButton iconPosition={iconPosition} onClick={onToggleGenerator}>
<Icon src={iconSrc} width={tgIconSize} height={tgIconSize} />
{buttonIcon ? (
buttonIcon
) : (
<Icon src={toggleButton} width={tgIconSize} height={tgIconSize} />
)}
</TGOpenButton>
)}
</TGPortal>
Expand Down
12 changes: 4 additions & 8 deletions src/stories/components/ThumbnailGenerator.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import { toggleButton, fill } from '../../assets/icons';
export default {
title: 'components/ThumbnailGenerator',
argTypes: {
iconSrc: {
options: [toggleButton, fill],
control: { type: 'select' },
},
modalPosition: {
options: ['left', 'right', 'center'],
control: { type: 'select' },
Expand All @@ -24,7 +20,7 @@ export default {

interface Props {
iconSize?: Size;
iconSrc?: string;
buttonIcon?: React.ReactNode;
modalPosition?: 'left' | 'right' | 'center';
iconPosition?: [number, number, number, number];
}
Expand All @@ -33,12 +29,12 @@ const Template: Story = ({
modalPosition,
iconPosition,
iconSize,
iconSrc,
buttonIcon,
}: Props) => {
return (
<ThumbnailGenerator
id="thumbnail-generator"
iconSrc={iconSrc}
buttonIcon={buttonIcon}
modalPosition={modalPosition}
iconPosition={iconPosition}
iconSize={iconSize}
Expand All @@ -50,7 +46,7 @@ export const Default = Template.bind({});

Default.args = {
iconSize: 'medium',
iconSrc: toggleButton,
buttonIcon: <img src={toggleButton} width={40} height={40} />,
modalPosition: 'right',
iconPosition: [0, 20, 20, 0],
};

0 comments on commit 77ebdd8

Please sign in to comment.