Skip to content

Commit a8f8417

Browse files
Merge pull request #15 from sreeram-venkitesh/9-setup-common-textarea
Added common Textarea
2 parents 62bf996 + a41bca4 commit a8f8417

File tree

6 files changed

+93
-5
lines changed

6 files changed

+93
-5
lines changed

components/Button.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const Button = ({
77
size = "medium",
88
onClick = () => {},
99
disabled = false,
10-
label = "Clicked",
10+
label = "",
1111
...otherProps
1212
}) => {
1313
const handleClick = () => {

components/Textarea.jsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import classnames from "classnames";
2+
3+
const Textarea = ({
4+
placeholder = "",
5+
className = "",
6+
rows = 3,
7+
label = "",
8+
disabled = false,
9+
...otherProps
10+
}) => {
11+
return (
12+
<div className={classnames(["textarea__wrapper", className])}>
13+
{label && <label className="textarea-label">{label}</label>}
14+
<div
15+
className={classnames("textarea-input", {
16+
"textarea-disabled": disabled,
17+
})}
18+
>
19+
<textarea
20+
placeholder={placeholder}
21+
rows={rows}
22+
disabled={disabled}
23+
{...otherProps}
24+
/>
25+
</div>
26+
</div>
27+
);
28+
};
29+
30+
export default Textarea;

pages/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
import Head from "next/head";
22
import Footer from "../components/Footer";
33
import Button from "../components/Button";
4+
import Textarea from "../components/Textarea";
45

56
export default function Home() {
67
return (
7-
<div className="h-screen flex-col justify-between bg-black">
8+
<div className="h-screen flex-col justify-between bg-black p-5">
89
<Head>
910
<title>JSON Style</title>
1011
<meta name="description" content="Generated by create next app" />
1112
<link rel="icon" href="/favicon.ico" />
1213
</Head>
1314

1415
<main>
15-
<p className="text-2xl">Hello World!</p>
16-
<Button className="ml-1" label="Click Me" />
16+
<p className="text-2xl text-center">JSON STYLE</p>
17+
<div className="space-y-5">
18+
<Textarea
19+
className="w-1/2"
20+
rows={10}
21+
label="JSON String"
22+
onChange={(e) => console.log(e.target.value)}
23+
/>
24+
<Button className="ml-1" label="Click Me" />
25+
</div>
1726
</main>
1827
<Footer />
1928
</div>

styles/application.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77

88
// components
99
@import "./components/button";
10+
@import "./components/textarea";

styles/base/_index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
body {
2-
color: #ffffff;
2+
color: #e4e4e7;
33
}

styles/components/_textarea.scss

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.textarea__wrapper {
2+
display: flex;
3+
flex-direction: column;
4+
justify-content: flex-start;
5+
align-items: flex-start;
6+
flex-grow: 1;
7+
8+
.textarea-label {
9+
margin-bottom: 4px;
10+
}
11+
12+
.textarea-input {
13+
width: 100%;
14+
display: flex;
15+
flex-direction: row;
16+
justify-content: flex-start;
17+
align-items: center;
18+
font-size: 16px;
19+
color: #cbd5e1;
20+
background-color: #27272a;
21+
22+
textarea {
23+
width: 100%;
24+
color: inherit;
25+
border: none;
26+
font-size: inherit;
27+
box-shadow: none;
28+
outline: none;
29+
padding: 10px;
30+
max-height: 224px;
31+
overflow-y: auto;
32+
line-height: 1.5;
33+
background-color: #27272a;
34+
35+
&::placeholder {
36+
color: #e4e4e7;
37+
}
38+
}
39+
40+
&.textarea-disabled {
41+
cursor: not-allowed;
42+
opacity: 0.5;
43+
textarea {
44+
cursor: not-allowed;
45+
}
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)