-
Notifications
You must be signed in to change notification settings - Fork 1
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
docs: foundation 사용법 문서 작성 #31
Conversation
- displayName 속성을 사용함
모든 타이포그래피 스타일은 [Typo story](../?path=/story/foundation-typo--primary)에서 확인할 수 있습니다. | ||
|
||
```typescript | ||
import { styled } from 'styled-components'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Color 및 Typo 사용 시 형태
import { YDSTheme } from '@yourssu/design-system-react';
interface StyledButtonProps {
isFilled?: boolean;
}
export const StyledButton = styled.button<StyledButtonProps>`
height: 34px;
padding: 8px 32px;
border: none;
border-radius: 9999px;
background-color: ${({ isFilled, theme }: StyledButtonProps & { theme: YDSTheme }) =>
isFilled ? theme.color.buttonPoint : theme.color.buttonPoint};
font-style: ${({ theme }: { theme: YDSTheme }) => theme.typo.caption0};
`;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오.. 사용처에서 YDSTheme 타입이라고 매번 선언해주는 건 너무 불편한 거 같은데, YDS-React에서 해결할 순 없을까요?
YDSThemeProvider.tsx
보면 theme
이 YDSTheme 타입으로 선언은 되는데, ThemeProvider
인자로 넣으면서 타입을 잃어버리는 거 같...걸랑요
ThemeProvider.tsx
주석 보면 DefaultTheme
타입을 오버라이딩 하는 방법으로 해결해볼 수 있을 거 같은데 좀만 더 알아볼게용
/**
* Override DefaultTheme to get accurate typings for your project.
*
* ```
* // create styled-components.d.ts in your project source
* // if it isn't being picked up, check tsconfig compilerOptions.types
* import type { CSSProp } from "styled-components";
* import Theme from './theme';
*
* type ThemeType = typeof Theme;
*
* declare module "styled-components" {
* export interface DefaultTheme extends ThemeType {}
* }
*
* declare module "react" {
* interface DOMAttributes<T> {
* css?: CSSProp;
* }
* }
* ```
*/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 저도 매번 선언해주는 건 불편한 것 같아요!! 근데 궁금한 점이 theme 자체를 오버라이딩 하게 되면 YDS 컬러랑 일반적인(다른) 컬러랑 동시에 사용하고 싶을 때는 혹쉬 DefaultTheme을 어떻게 사용할 수 있을까욥..??
=> 저도 좀 더 알아보겠슴다!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 컬러 = YDS에 정의되지 않은 컬러가 맞나요?
그렇다면 그 색상은 theme을 통해 불러올 수 없으니까 (theme.color에 정의된 게 아니니까)
그냥 헥사코드 그대로 사용해야 할 거라고 이해했는데 이게 지금 질문을 이해한 답변인지..................................
그리고 저 오버라이딩을 YDS-React에서 해서 내보내면 될 거 같았는데 ㅠ 사용처에서 해야 하는 거 같아욕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
옹 그렇네요👀👀 오버라이딩 된다면 해당 부분에 추가적인 속성을 정의했을 때 의도한대로 동작할 것 같아용!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사용처에서 styeld-component.d.ts 만드는 걸로 가닥이 잡힌 거 같은데 ........ 맞다면 여기 어푸루브 해주시면 합쳐둘게요~! ^ㅅ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
엇 저는 타입 에러 터질 때 작동도 안 했었어서..! import 하는 방식이랑 styled.d.ts 만드는 거 둘 다 적어두면 좋을 것 같은데 어떻게 생각하시나용??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
타입 에러가 발생했다 = foundation or semantic name에서 오타남 = 작동 안 하는 게 정상이라고.... 생각햇습니다.........
이 상황에서 작동을 할 수가 없지 않나요..?! (⊙o⊙)
style.ts 내에서 직접 import 하는 방식은 styled.d.ts 파일 생성으로 대체할 수 있고,
사실 권장하는.... 방법이 아니니까..... 후자만 적어도 좋을 거 같다고 생각합니다~~!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
짱짱 수고하셨숩니당~!!!!!
1️⃣ 어떤 작업을 했나요? (Summary)
foundation 사용법을 담은 mdx 문서 초안 작성
![Group 1000011840](https://private-user-images.githubusercontent.com/87255462/302094096-002dbb82-07a1-407c-a6d7-5b027a2f1cc6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5MDMxMzUsIm5iZiI6MTczODkwMjgzNSwicGF0aCI6Ii84NzI1NTQ2Mi8zMDIwOTQwOTYtMDAyZGJiODItMDdhMS00MDdjLWE2ZDctNWIwMjdhMmYxY2M2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDA0MzM1NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU3MDFjNzMxNDQxYmUxZjdiZGZhNTU4NzdkMmJiYmMwZDUxZWU4MDNhYjg0OTMxNWNlYzJmOTFhMzExMDhjNWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.4ZyzcFfDstuxtJpf6SflCdvgoM9wBF6U7hRWeLqP3Jw)
2️⃣ 알아두시면 좋아요!
Color, Icon, Typo 각각의 내용이 그렇게 길지 않아서, 하나의 파일로 작성해봤는데 우떠세용
(
founcdation.mdx
중 Icon 파트에는 IconContext의 내용을 그대로 가져온 상태)3️⃣ 추후 작업
4️⃣ 체크리스트 (Checklist)
main
브랜치의 최신 코드를pull
받았나요?