Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Feat ] Toggle Button 퍼블리싱 #21

Merged
merged 5 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions next.config.mjs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3) json 린트 설정이 다른 것 같아요 .. 계속해서 불필요한 변경사항들이 생기네요
어떻게 해결하면 좋을까요 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인해보겠습니다 . . .

Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/** @type {import('next').NextConfig} */
import { createVanillaExtractPlugin } from '@vanilla-extract/next-plugin';
import { createVanillaExtractPlugin } from "@vanilla-extract/next-plugin";
const withVanillaExtract = createVanillaExtractPlugin();

const nextConfig = {
webpack(config) {
// SVG imports를 처리하는 기존 규칙 가져오기
const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.('.svg'));
const fileLoaderRule = config.module.rules.find((rule) =>
rule.test?.test?.(".svg")
);

config.module.rules.push(
// svg imports 중 ?url로 끝나는 것에 대해서만 기존 규칙을 재적용
Expand All @@ -19,8 +21,8 @@ const nextConfig = {
test: /\.svg$/i,
issuer: fileLoaderRule.issuer,
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
use: ['@svgr/webpack'],
},
use: ["@svgr/webpack"],
}
);

// 처리가 완료된 *.svg를 무시하도록 파일 로더 규칙을 수정
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
},
"dependencies": {
"@vanilla-extract/css": "^1.15.5",
"@vanilla-extract/recipes": "^0.5.5",
"jotai": "^2.9.3",
"next": "14.2.8",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@svgr/webpack": "^8.1.0",
"@biomejs/biome": "1.8.3",
"@svgr/webpack": "^8.1.0",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Providers from "@/components/common/Provider";
import Providers from "@/components/common/Provider/Provider";
import type { Metadata } from "next";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p4) 컴포넌트 폴더에 파일명은 index.tsx 로 통일하는 것은 어떻게 생각하시나요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FE 팀원들과 논의된 사항인가요 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다른 분들의 의견도 궁금합니다!

import "./globals.css";

Expand Down
23 changes: 9 additions & 14 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { IcnAlarm } from "@/assets/svgs";
import AlarmUrl from "@/assets/svgs/icn_alarm.svg?url";
import Image from "next/image";
"use client";

import ToggleButton from "@/components/common/ToggleButton/ToggleButton";
import { useState } from "react";

export default function Home() {
const [isClicked, setIsClicked] = useState(false);

return (
<div className="text-purple">
<IcnAlarm width={50} height={50} />
<Image width={50} height={50} src={AlarmUrl} alt="alarm" priority />
<img width={50} height={50} src={AlarmUrl.src} alt="alarm" />
<div
style={{
width: 50,
height: 50,
backgroundImage: `url(${AlarmUrl.src})`,
backgroundRepeat: "no-repeat",
backgroundSize: "cover",
}}
<ToggleButton
isSelected={isClicked}
onChange={() => setIsClicked((prev) => !prev)}
/>
</div>
);
Expand Down
51 changes: 51 additions & 0 deletions src/components/common/ToggleButton/ToggleButton.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { recipe } from "@vanilla-extract/recipes";

export const buttonStyle = recipe({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우왕 신기하당 !
덕분에 좋은 기능들 알아가네요! 감사합니다 👍

base: {
position: "relative",

appearance: "none",

width: "40px",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p2) 단위 rem으로 통일하는 건 어떻게 생각하시나요? global.css 에 '65.7%' 인지 뭔지 하는 거 설정해두었거든요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 수정하겠습니다 ~

height: "24px",

padding: "2px",

borderRadius: "16px",
backgroundColor: "rgba(121, 130, 154, 1)",

cursor: "pointer",

":before": {
content: "",

position: "absolute",
top: 0,
bottom: 0,

zIndex: 1,

width: "20px",
height: "20px",
margin: "auto 0",

backgroundColor: "rgba(188, 192, 205, 1)",
borderRadius: "50%",

transition: "all .3s ease-out",
},
},
variants: {
active: {
true: {
backgroundColor: "rgba(102, 89, 255, 1)",

":before": {
backgroundColor: "rgba(255, 255, 255, 1)",

transform: "translateX(16px)",
},
},
},
},
});
27 changes: 27 additions & 0 deletions src/components/common/ToggleButton/ToggleButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { buttonStyle } from "@/components/common/ToggleButton/ToggleButton.css";
import type { ComponentPropsWithoutRef } from "react";

interface ToggleButtonProps extends ComponentPropsWithoutRef<"input"> {
isSelected: boolean;
onChange: () => void;
}

const ToggleButton = ({
isSelected,
onChange,
...props
}: ToggleButtonProps) => {
return (
<input
type="checkbox"
role="switch"
aria-checked={isSelected}
checked={isSelected}
onChange={onChange}
className={buttonStyle({ active: isSelected })}
{...props}
/>
);
};

export default ToggleButton;
Loading