[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,91 +2,181 @@
|
||||
id: wiki-2026-0508-styletron
|
||||
title: Styletron
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [Styletron CSS-in-JS]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [uncategorized]
|
||||
confidence_score: 0.85
|
||||
verification_status: applied
|
||||
tags: [css-in-js, styling, frontend, react]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-08
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: typescript
|
||||
framework: react
|
||||
---
|
||||
|
||||
# [[Styletron|Styletron]]
|
||||
# Styletron
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
Styletron은 Uber의 Base Web 디자인 시스템에서 활용되는 스타일링 도구로, 아토믹 스타일링(atomic styling)을 생성하여 웹 애플리케이션이 다운로드해야 하는 콘텐츠의 양을 최소화하는 역할을 합니다 [1]. 이를 통해 모바일 기기 사용자나 네트워크 연결이 열악한 환경에서도 성능이 최적화될 수 있도록 돕습니다 [1]. 다만, 이 외의 구체적인 작동 원리나 아키텍처에 대한 소스에 관련 정보가 부족합니다.
|
||||
## 매 한 줄
|
||||
> **"매 atomic CSS-in-JS 의 pioneer"**. Uber 가 만든 styling library — 매 declared style 을 atomic class (`.a { color: red }`) 로 deduplicate, 매 SSR-friendly. 2026 perspective: 매 historical interest — 현재 의 mainstream 은 zero-runtime (vanilla-extract, Linaria, Panda CSS) 또는 utility (Tailwind v4).
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
* **아토믹 스타일링(Atomic Styling) 생성**: Styletron은 CSS를 아토믹한 단위로 생성함으로써 스타일 코드가 차지하는 용량을 줄이고, 웹 애플리케이션이 로드할 때 다운로드하는 콘텐츠를 최소화합니다 [1].
|
||||
* **성능 및 환경 최적화**: 생성된 아토믹 스타일을 통해 컴퓨팅 파워가 부족한 모바일 기기나 네트워크 환경이 좋지 않은 사용자들에게 최적화된 UI 성능을 제공하는 데 핵심적인 기여를 합니다 [1].
|
||||
* **Base Web과의 통합**: 접근성과 안정성을 중시하는 Uber의 오픈소스 React 컴포넌트 라이브러리인 Base Web에서 성능 최적화를 위한 기반 도구로 채택되어 활용되고 있습니다 [1].
|
||||
* 소스에 관련 정보가 부족합니다. (Styletron의 세부적인 문법, 내부 동작 원리, 다른 [[CSS-in-JS|CSS-in-JS]] 또는 [[Tailwind CSS|Tailwind CSS]]와의 직접적인 성능 비교 등 깊이 있는 기술적 정보는 제공되지 않습니다.)
|
||||
## 매 핵심
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** Atomic Styling, Base Web, [[Design Systems|DesignSystems]]
|
||||
- **Projects/Contexts:** [[Uber Base Web|Uber Base Web]] React Component Library
|
||||
- **Contradictions/Notes:** 소스에 관련 정보가 부족합니다. (Styletron과 다른 스타일링 접근법 간의 상충되는 의견이나 한계점은 소스에 명시되어 있지 않습니다.)
|
||||
### 매 idea
|
||||
- 매 styled component 의 declared CSS 를 atomic single-property class 로 split.
|
||||
- 매 동일 declaration 은 한 class 의 share → 매 small bundle.
|
||||
- Runtime 의 dedupe + SSR 의 style extract.
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-26*
|
||||
### 매 Styletron 의 modern 위치
|
||||
- 매 BaseWeb (Uber UI lib) 의 default styling engine.
|
||||
- Production 사용 의 still alive 그러나 매 new project 의 default 가 아님.
|
||||
- 매 atomic 의 idea 는 Tailwind / UnoCSS 가 inherit (compile-time).
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 modern alternatives (2026)
|
||||
- **vanilla-extract**: zero-runtime, type-safe.
|
||||
- **Panda CSS**: build-time atomic.
|
||||
- **Tailwind CSS v4**: 매 utility-first mainstream.
|
||||
- **CSS Modules + plain CSS**: 매 simplest baseline.
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### 매 응용
|
||||
1. BaseWeb component library 사용.
|
||||
2. Legacy Uber-stack codebase 유지보수.
|
||||
3. 매 historical case study (atomic CSS 의 origin).
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
## 💻 패턴
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
### Setup (React)
|
||||
```typescript
|
||||
import { Provider as StyletronProvider } from "styletron-react";
|
||||
import { Client as Styletron } from "styletron-engine-atomic";
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
const engine = new Styletron();
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
|
||||
- **과거 데이터와의 충돌:** 없음
|
||||
- **정책 변화:** 없음
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
export function App() {
|
||||
return (
|
||||
<StyletronProvider value={engine}>
|
||||
<Page />
|
||||
</StyletronProvider>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### styled component
|
||||
```typescript
|
||||
import { styled } from "styletron-react";
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
const Button = styled("button", {
|
||||
backgroundColor: "blue",
|
||||
color: "white",
|
||||
padding: "8px 16px",
|
||||
borderRadius: "4px",
|
||||
});
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
// usage: <Button>Click</Button>
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### Dynamic prop-based styling
|
||||
```typescript
|
||||
const Button = styled<"button", { $primary?: boolean }>("button", ({ $primary }) => ({
|
||||
backgroundColor: $primary ? "blue" : "gray",
|
||||
color: "white",
|
||||
}));
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### useStyletron hook
|
||||
```typescript
|
||||
import { useStyletron } from "styletron-react";
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
function Card() {
|
||||
const [css] = useStyletron();
|
||||
return <div className={css({ padding: "16px", boxShadow: "0 2px 4px rgba(0,0,0,0.1)" })}>Hello</div>;
|
||||
}
|
||||
```
|
||||
|
||||
### SSR (Next.js)
|
||||
```typescript
|
||||
// pages/_document.tsx
|
||||
import Document, { Html, Head, Main, NextScript } from "next/document";
|
||||
import { Server, Sheet } from "styletron-engine-atomic";
|
||||
import { Provider } from "styletron-react";
|
||||
|
||||
export default class MyDoc extends Document {
|
||||
static async getInitialProps(ctx) {
|
||||
const engine = new Server();
|
||||
const initialProps = await Document.getInitialProps({
|
||||
...ctx,
|
||||
renderPage: () => ctx.renderPage({
|
||||
enhanceApp: (App) => (props) => (
|
||||
<Provider value={engine}><App {...props} /></Provider>
|
||||
),
|
||||
}),
|
||||
});
|
||||
return { ...initialProps, stylesheets: engine.getStylesheets() };
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<Html>
|
||||
<Head>
|
||||
{this.props.stylesheets.map((s, i) => (
|
||||
<style className="_styletron_hydrate_" dangerouslySetInnerHTML={{ __html: s.css }} key={i} />
|
||||
))}
|
||||
</Head>
|
||||
<body><Main /><NextScript /></body>
|
||||
</Html>
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Migration to vanilla-extract (modern)
|
||||
```typescript
|
||||
// styles.css.ts
|
||||
import { style } from "@vanilla-extract/css";
|
||||
export const button = style({
|
||||
backgroundColor: "blue",
|
||||
color: "white",
|
||||
padding: "8px 16px",
|
||||
});
|
||||
// Component.tsx
|
||||
import { button } from "./styles.css";
|
||||
<button className={button}>Click</button>
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| 매 BaseWeb 사용 codebase | Styletron (forced) |
|
||||
| 매 new project (2026) | Tailwind v4 또는 vanilla-extract |
|
||||
| 매 type-safe + zero-runtime | vanilla-extract |
|
||||
| 매 quick prototype | Tailwind |
|
||||
| 매 library 배포 (no runtime) | Linaria / Panda CSS |
|
||||
|
||||
**기본값**: 매 new code 는 Tailwind v4 또는 vanilla-extract. 매 Styletron 신규 채택 의 X.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[CSS-in-JS]] · [[Styling]]
|
||||
- 변형: [[vanilla-extract]] · [[Panda-CSS]] · [[Linaria]] · [[Emotion]]
|
||||
- 응용: [[BaseWeb]] · [[React]]
|
||||
- Adjacent: [[Tailwind-CSS]] · [[Atomic-CSS]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: BaseWeb codebase 의 maintenance, 매 atomic CSS history 의 understand.
|
||||
**언제 X**: 매 greenfield project — modern alternatives 가 superior (zero-runtime, type-safe).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **매 new project 의 Styletron 채택**: 매 ecosystem momentum 이 vanilla-extract / Tailwind 로 이동 — 매 future-proof X.
|
||||
- **Runtime dedupe overhead**: 매 large app 에서 visible — 매 build-time atomic (Panda) 이 우월.
|
||||
- **Styletron + Tailwind 동시**: 매 conflicting paradigm — pick one.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (styletron.org, GitHub uber/styletron, Uber engineering blog 2017).
|
||||
- 신뢰도 A (매 historically), 매 modern adoption 의 declining.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — atomic CSS-in-JS + modern alternatives positioning |
|
||||
|
||||
Reference in New Issue
Block a user