Skip to content

Commit 2c098bf

Browse files
committed
feat: Add isDefaultOpen props
1 parent f2b77b1 commit 2c098bf

File tree

7 files changed

+28
-17
lines changed

7 files changed

+28
-17
lines changed

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
<br/>
3535

36-
<h3 align="center">🌟 CONTRIBUTORS 🌟</h3>
36+
<h3 align="center">🌟 CONTRIBUTORS 🌟=</h3>
3737
<p align="center">
3838
<a href="https://github.com/ssi02014/react-thumbnail-generator/graphs/contributors">
3939
<img src="https://contrib.rocks/image?repo=ssi02014/react-thumbnail-generator">
@@ -42,7 +42,7 @@
4242

4343
<br />
4444

45-
<h3 align="center">Storybook Github Page</h3>
45+
<h3 align="center">Storybook: Demo Page</h3>
4646
<p align="center">
4747
<a href="https://ssi02014.github.io/react-thumbnail-generator/?path=/story/components-thumbnailgenerator--default">
4848
<img src="https://user-images.githubusercontent.com/64779472/220122236-c90ae4a5-8271-41df-b150-230b97991d41.png" width="120">
@@ -76,7 +76,7 @@
7676
- Dragging and dropping text on the canvas
7777
- Adding custom web font families
7878
- Selecting the modal button and its location
79-
- Choosing the image type (png, jpg, webp)
79+
- Choosing the image type (png, jpg, webp, svg)
8080
- Supporting TypeScript and Next
8181

8282

@@ -146,22 +146,24 @@ const App = () => {
146146
// If you do not include this option, the default icon will be used.
147147

148148
iconSize="medium"
149-
// Please select the size of the default button icon.
150-
// If no size is specified, the default size (medium) will be applied.
149+
// Through this property, you can specify the size of the button icon.
151150
// However, if you are inserting a custom button icon, this option is meaningless.
152151

153152
iconPosition={[0, 20, 20, 0]}
154-
// Please select the location of the button to open the Thumbnail Model.
155-
// Sequence: [top, right, bottom, left]
153+
// Through this property, you can specify the position of the button icon.
154+
// [top, right, bottom, left]
156155

157156
modalPosition='right'
158-
// Please select the location to open the ThumbnailModal.
157+
// Through this property, you can specify the position of the thumbnail generator.
159158

160159
additionalFontFamily={['Noto Sans', ...]}
161160
// You can add the font of your choice to your project, but that font must already applied to your project.
162161

163162
isFullWidth={true}
164-
// Setting this property to true will make the thumbnail generator modal full width.
163+
// Setting this property to true will make the thumbnail generator full-width.
164+
165+
isDefaultOpen={false}
166+
// Setting this property to true will open the thumbnail generator by default.
165167
/>
166168
</div>
167169
)
@@ -301,9 +303,15 @@ const App = () => {
301303
- **Optional**
302304
- Default: `false`
303305
- Type: `boolean`
306+
- isDefaultOpen
307+
- **Optional**
308+
- Default: `false`
309+
- Type: `boolean`
304310

305311
<br />
306312

307313
## Reference
308314
- https://github.com/wormwlrm/kwakcheolyong
309-
- https://github.com/banner-maker/banner-makers
315+
- https://github.com/banner-maker/banner-makers
316+
317+
<br />

src/components/Canvas/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,13 @@ const Canvas = React.forwardRef(({ canvasState }: CanvasProps, ref: any) => {
122122
const ctx = canvas.getContext('2d');
123123

124124
if (!ctx) return;
125+
125126
if (selectedImage) {
126127
if (isBlur) ctx.filter = 'blur(5px)';
127128
ctx.drawImage(selectedImage, 0, 0);
128129
return;
129130
}
131+
130132
ctx.fillStyle = bgColor.hex;
131133
ctx.fillRect(0, 0, canvas.width, canvas.height);
132134
};

src/components/Inputs/RangeInput/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const RangeInput = ({
3636
backgroundSize={backgroundSize}
3737
/>
3838
</S.InputLabelRangeContainer>
39-
<TextInput width={60} name={name} value={value} onChange={onChange} />
39+
<TextInput width={50} name={name} value={value} onChange={onChange} />
4040
</S.RangeInputWrapper>
4141
);
4242
};

src/components/Inputs/TextInput/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const TextInput = ({
1616
}: TextInputProps) => {
1717
return (
1818
<S.TextInputWrapper width={width}>
19-
<label htmlFor={name}>{label}</label>
19+
{label && <label htmlFor={name}>{label}</label>}
2020
<input
2121
type="text"
2222
name={name}

src/lib/ThumbnailGenerator.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Icon from '@components/Icon';
88

99
interface ThumbnailGeneratorProps {
1010
id?: string;
11+
isDefaultOpen?: boolean;
1112
buttonIcon?: React.ReactNode;
1213
iconSize?: 'small' | 'medium' | 'large';
1314
position?: Position;
@@ -20,13 +21,14 @@ interface ThumbnailGeneratorProps {
2021
const ThumbnailGenerator = ({
2122
id,
2223
buttonIcon,
24+
isDefaultOpen = false,
2325
iconSize = 'medium',
2426
iconPosition = [0, 20, 20, 0],
2527
modalPosition = 'right',
2628
isFullWidth = false,
2729
additionalFontFamily = [],
2830
}: ThumbnailGeneratorProps) => {
29-
const [isOpen, setIsOpen] = useState(false);
31+
const [isOpen, setIsOpen] = useState(isDefaultOpen);
3032
const tgIconSize = getIconSize(iconSize);
3133

3234
const onToggleGenerator = () => {

src/stories/components/ThumbnailGenerator.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const Template: Story = ({
4343
iconPosition={iconPosition}
4444
iconSize={iconSize}
4545
isFullWidth={isFullWidth}
46+
isDefaultOpen
4647
/>
4748
);
4849
};

src/utils/common.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ export type ValidType = 'imageSize' | 'canvasSize' | 'angle' | 'lineHeight';
55

66
export const getValidMessage = (condition: boolean, type: ValidType) => {
77
const message = {
8-
imageSize: `Please register a picture smaller than "Limit Width"`,
9-
canvasSize: `Please set the canvas width smaller than "Limit Width"`,
10-
angle: 'Please set a value in the range of -360 to 360',
11-
lineHeight: 'Please set a value in the range of 0 to 360',
8+
angle: 'Please set the value to within the range',
9+
lineHeight: 'Please set the value to within the range',
1210
} as { [key: string]: string };
1311

1412
if (condition) return message[type];

0 commit comments

Comments
 (0)