Skip to content

Commit

Permalink
Merge pull request #3 from salino3/add-input
Browse files Browse the repository at this point in the history
Add input
  • Loading branch information
salino3 authored Jun 16, 2024
2 parents 41c4d05 + 7ac58fb commit c0ae751
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
/>

<title>Vite + React + TS</title>
<title>My web React</title>
</head>
<body>
<div id="root"></div>
Expand Down
6 changes: 4 additions & 2 deletions src/index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
:root {
--color-one: #fafafa;
--color-two: #4f56ec;
--color-two: #112a46;
--color-three: #acc8e5;
}

html,
Expand All @@ -15,5 +16,6 @@ html {
}

body {
background-color: #777dff;
color: var(--color-two);
background-color: var(--color-three);
}
10 changes: 9 additions & 1 deletion src/layouts/home/home.styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,13 @@
padding: 0;
margin: 0;
position: relative;
overflow-y: hidden;
padding-bottom: 3rem;

overflow-y: scroll;
-ms-overflow-style: none; // IE 10+
scrollbar-width: none; // Firefox

&::-webkit-scrollbar {
display: none; // Chrome, Safari, Opera
}
}
1 change: 1 addition & 0 deletions src/pods/home/components/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./image-rotate";
export * from "./input-text";
1 change: 1 addition & 0 deletions src/pods/home/components/input-text/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./input-text.component";
34 changes: 34 additions & 0 deletions src/pods/home/components/input-text/input-text.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { useState } from "react";
import "./input-text.styles.scss";

export const CustomInputText: React.FC = () => {
const [inputValue, setInputValue] = useState("");

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setInputValue(event.target.value);
};

return (
<div className="rootCustomInputText">
<div className="containerTitle">
<h2>Custom Text Input</h2>
</div>
<div className="containerInput">
<input
type="text"
id="city"
className="inputText"
name="city"
value={inputValue}
onChange={handleChange}
/>
<label
htmlFor="city"
className={`inputLabel ${inputValue ? "shrink" : ""}`}
>
What city do you live?
</label>
</div>
</div>
);
};
44 changes: 44 additions & 0 deletions src/pods/home/components/input-text/input-text.styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.rootCustomInputText {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 1rem;

.containerInput {
position: relative;
width: 50%;

.inputText {
border-radius: 0.5rem;
padding: 1rem 0.5rem 0.5rem 1rem;
box-shadow: var(--color-two) 0px 0px 16px;
width: 100%;
outline: none;
border: 0.5px solid;
}

.inputLabel {
position: absolute;
top: 50%;
left: 1rem;
transform: translateY(-50%);
transition: all 0.3s ease;
pointer-events: none;
color: #999;
}

.inputText:focus + .inputLabel,
.shrink {
top: 0;
left: 1rem;
font-size: 0.8rem;
transform: translateY(-110%);
color: black;
}

.inputText:focus {
box-shadow: #ffec1f 0px 0px 16px;
}
}
}
17 changes: 13 additions & 4 deletions src/pods/home/home.component.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { RotateImage } from "./components";
import { CustomInputText, RotateImage } from "./components";
import "./home.styles.scss";

export const HomePage: React.FC = () => {
Expand Down Expand Up @@ -35,9 +35,18 @@ export const HomePage: React.FC = () => {
data?.length > 0 &&
data.map((item) => <p key={item?.id}>{item?.name}</p>)}
</div> */}
<div className="containerRotate">
<RotateImage />
</div>
<details>
<summary>Rotate Image</summary>
<div className="containerRotate">
<RotateImage />
</div>
</details>
<details>
<summary>Custom Text Input Styles</summary>
<div className="containerInput">
<CustomInputText />
</div>
</details>
</div>
</div>
);
Expand Down
10 changes: 10 additions & 0 deletions src/pods/home/home.styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
border-width: 1px;
padding: 1rem 2rem 5rem;
width: 500px;
gap: 2rem;

details {
width: 100%;
summary {
cursor: pointer;
width: fit-content;
}
}

.listhomePage {
display: flex;
flex-direction: column;
Expand Down

0 comments on commit c0ae751

Please sign in to comment.