This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (() => { | |
| 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()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ -f save.json ] || echo '{}' > save.json && docker run --rm \ | |
| -e COSMIUM_PERSIST=/save.json \ | |
| -e COSMIUM_DISABLETLS=true \ | |
| -e COSMIUM_ACCOUNTKEY=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw== \ | |
| -v ./save.json:/save.json \ | |
| -p 8081:8081 \ | |
| ghcr.io/pikami/cosmium:explorer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @see: https://stackoverflow.com/questions/72757228/mutate-useswr-data-local-state-without-revalidating | |
| */ | |
| import React from "react"; | |
| import useSWR from "swr"; | |
| const fetcher = async (url) => { | |
| await new Promise(resolve => setTimeout(resolve, 1000)); | |
| return fetch(url).then((res) => res.json()) | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export {}; | |
| /** | |
| * In both methods above, the options parameter provides a way to further manipulate page content | |
| * based on whether consent for a group of cookies has been given. | |
| * This provides a simple mechanism that enables website owners to either incentivize users to opt-in or deliver | |
| * a different user experience to visitors who opt-out. | |
| * @see https://my.onetrust.com/articles/en_US/Knowledge/UUID-518074a1-a6da-81c3-be52-bae7685d9c94 | |
| */ | |
| type OneTrustInsertScriptOptions = { | |
| /** Delete all parent container content before inserting the element */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import chalk from 'chalk'; | |
| import * as fs from 'fs'; | |
| import * as path from 'path'; | |
| import * as util from 'util'; | |
| const copyFile = util.promisify(fs.copyFile); | |
| interface SyncOptions { | |
| sourceDir: string; | |
| targetDir: string; |
NewerOlder