See live demo here: https://codepen.io/lorobi/pen/XJdoQPP Other solutions: https://stackoverflow.com/questions/11167628/trees-in-twitter-bootstrap/11170897#11170897
- 1
- 1.1
- 1.2
- 1.2.1
- 1.2.2
- 1.2.2.1
- 1.2.2.2
| // build.js | |
| import ts from "typescript"; | |
| import path from "path"; | |
| async function build() { | |
| const projectDir = path.resolve("./packages/ds-tokens"); | |
| const configPath = path.join(projectDir, "tsconfig.build.json"); | |
| // 1. Charger tsconfig | |
| const configFile = ts.readConfigFile(configPath, ts.sys.readFile); |
| // src/variants.ts | |
| export type VariantDef = Record<string, readonly string[]>; | |
| export type VariantProps<T extends VariantDef> = { | |
| [K in keyof T]?: T[K][number]; | |
| } & { class?: string }; | |
| // src/factory.ts | |
| import { cva } from "class-variance-authority"; | |
| import type { VariantDef, VariantProps as PublicProps } from "./variants"; |
| // radio-group.component | |
| import { Component, ContentChildren, QueryList, forwardRef } from '@angular/core'; | |
| import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; | |
| import { RadioItemComponent } from './radio-item.component'; | |
| let nextId = 0; | |
| @Component({ | |
| selector: 'radio-group', |
| type CssPath<T extends string> = | |
| T extends `--${infer Rest}` // enlève les "--" du début | |
| ? ReplaceDashWithSlash<Rest> // remplace les tirets restants | |
| : never | |
| type ReplaceDashWithSlash<S extends string> = | |
| S extends `${infer Head}-${infer Tail}` | |
| ? `${Head}/${ReplaceDashWithSlash<Tail>}` | |
| : S |
| export const isElementFullyVisible = (element: HTMLElement, topThreshold = 0) => { | |
| if (window && document) { | |
| const windowHeight = window.innerHeight || document.documentElement.clientHeight; | |
| const rect = element.getBoundingClientRect(); | |
| return rect.top > topThreshold && rect.bottom < windowHeight; | |
| } | |
| return false; | |
| }; | |
| export function scrollParentToChild(parent: Element, child: Element, threshold = 100): void { | |
| // Where is the parent on page |
| (() => { | |
| let count = 0; | |
| const removeInRoot = root => { | |
| const styles = root.querySelectorAll('style'); | |
| styles.forEach(s => s.remove()); | |
| count += styles.length; | |
| const stylesLinks = root.querySelectorAll('link[rel="stylesheet"]'); | |
| stylesLinks.forEach(s => s.remove()); |
See live demo here: https://codepen.io/lorobi/pen/XJdoQPP Other solutions: https://stackoverflow.com/questions/11167628/trees-in-twitter-bootstrap/11170897#11170897
| import { compile } from "tailwindcss"; | |
| const run = async () => { | |
| const compiledContent = ( | |
| await compile(` | |
| @theme { | |
| --container-md: 700px; | |
| } | |
| .test { | |
| color: red; |