├── .yarnrc ├── packages ├── react-css-styled │ ├── src │ │ ├── react-app-env.d.ts │ │ ├── react-css-styled │ │ │ ├── index.ts │ │ │ ├── index.umd.ts │ │ │ ├── index.cjs.ts │ │ │ ├── StyledElement.tsx │ │ │ └── styled.tsx │ │ ├── index.css │ │ ├── index.tsx │ │ ├── App.css │ │ ├── logo.svg │ │ ├── serviceWorker.ts │ │ └── App.tsx │ ├── public │ │ ├── favicon.ico │ │ ├── manifest.json │ │ └── index.html │ ├── tsconfig.build.json │ ├── .npmignore │ ├── tsconfig.declaration.json │ ├── tsconfig.json │ ├── rollup.config.js │ ├── README.md │ ├── LICENSE │ └── package.json ├── croact-css-styled │ ├── src │ │ ├── index.ts │ │ ├── index.esm.ts │ │ ├── styled.js │ │ ├── index.cjs.ts │ │ └── styled.d.ts │ ├── tsconfig.declaration.json │ ├── tsconfig.json │ ├── rollup.config.js │ └── package.json ├── preact-css-styled │ ├── src │ │ ├── preact-css-styled │ │ │ ├── index.esm.ts │ │ │ ├── index.ts │ │ │ ├── styled.js │ │ │ ├── index.cjs.ts │ │ │ └── styled.d.ts │ │ └── demo │ │ │ ├── index.tsx │ │ │ ├── App.css │ │ │ └── App.tsx │ ├── tsconfig.build.json │ ├── .npmignore │ ├── tsconfig.declaration.json │ ├── tsconfig.json │ ├── rollup.config.demo.js │ ├── public │ │ └── index.html │ ├── README.md │ ├── LICENSE │ ├── rollup.config.js │ └── package.json └── css-styled │ ├── src │ ├── index.cjs.ts │ ├── types.ts │ ├── styled.ts │ └── utils.ts │ ├── tsconfig.declaration.json │ ├── tsconfig.json │ ├── rollup.config.js │ ├── package.json │ └── README.md ├── tsconfig.declaration.json ├── .gitignore ├── tsconfig.test.json ├── .npmignore ├── .editorconfig ├── scripts └── custom.js ├── jest.config.js ├── tsconfig.json ├── rollup.config.js ├── lerna.json ├── tslint.json ├── LICENSE ├── jsdoc.json ├── package.json └── README.md /.yarnrc: -------------------------------------------------------------------------------- 1 | workspaces-experimental true 2 | -------------------------------------------------------------------------------- /packages/react-css-styled/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /packages/croact-css-styled/src/index.ts: -------------------------------------------------------------------------------- 1 | import styled from "./styled"; 2 | 3 | export * from "./styled"; 4 | export default styled; 5 | -------------------------------------------------------------------------------- /packages/croact-css-styled/src/index.esm.ts: -------------------------------------------------------------------------------- 1 | import styled from "./styled"; 2 | 3 | export * from "./styled"; 4 | export default styled; 5 | -------------------------------------------------------------------------------- /packages/react-css-styled/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daybrush/css-styled/HEAD/packages/react-css-styled/public/favicon.ico -------------------------------------------------------------------------------- /packages/preact-css-styled/src/preact-css-styled/index.esm.ts: -------------------------------------------------------------------------------- 1 | import styled from "./styled"; 2 | 3 | export * from "./styled"; 4 | export default styled; 5 | -------------------------------------------------------------------------------- /packages/preact-css-styled/src/preact-css-styled/index.ts: -------------------------------------------------------------------------------- 1 | import styled from "./styled"; 2 | 3 | export * from "./styled"; 4 | export default styled; 5 | -------------------------------------------------------------------------------- /packages/css-styled/src/index.cjs.ts: -------------------------------------------------------------------------------- 1 | import styled from "./styled"; 2 | 3 | module.exports = styled; 4 | export default styled; 5 | export * from "./styled"; 6 | -------------------------------------------------------------------------------- /packages/preact-css-styled/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "jsx": "react", 5 | "jsxFactory": "h" 6 | }, 7 | } -------------------------------------------------------------------------------- /packages/preact-css-styled/src/demo/index.tsx: -------------------------------------------------------------------------------- 1 | import { render, h } from "preact"; 2 | import App from "./App"; 3 | 4 | render(, document.getElementById("root")!); 5 | -------------------------------------------------------------------------------- /packages/react-css-styled/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "jsx": "react", 5 | "jsxFactory": "h", 6 | }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/croact-css-styled/src/styled.js: -------------------------------------------------------------------------------- 1 | import defaultStyled, { StyledElement, styled } from "react-css-styled"; 2 | export { StyledElement, styled }; 3 | export default defaultStyled; 4 | -------------------------------------------------------------------------------- /packages/preact-css-styled/src/preact-css-styled/styled.js: -------------------------------------------------------------------------------- 1 | import defaultStyled, { StyledElement, styled } from "react-css-styled"; 2 | export { StyledElement, styled }; 3 | export default defaultStyled; 4 | -------------------------------------------------------------------------------- /packages/react-css-styled/src/react-css-styled/index.ts: -------------------------------------------------------------------------------- 1 | import defaultStyled from "./styled"; 2 | 3 | export { StyledElement } from "./StyledElement"; 4 | export { styled } from "./styled"; 5 | export default defaultStyled; 6 | -------------------------------------------------------------------------------- /packages/react-css-styled/src/react-css-styled/index.umd.ts: -------------------------------------------------------------------------------- 1 | import styled, * as others from "./index"; 2 | 3 | for (const name in others) { 4 | (styled as any)[name] = (others as any)[name]; 5 | } 6 | export default styled; 7 | -------------------------------------------------------------------------------- /tsconfig.declaration.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "removeComments": true, 5 | "declaration": true, 6 | "emitDeclarationOnly": true, 7 | "declarationDir": "declaration" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/css-styled/tsconfig.declaration.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "removeComments": true, 5 | "declaration": true, 6 | "emitDeclarationOnly": true, 7 | "declarationDir": "declaration" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/croact-css-styled/tsconfig.declaration.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "removeComments": true, 5 | "declaration": true, 6 | "emitDeclarationOnly": true, 7 | "declarationDir": "declaration" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/croact-css-styled/src/index.cjs.ts: -------------------------------------------------------------------------------- 1 | import styled, * as modules from "./index"; 2 | 3 | for (const name in modules) { 4 | (styled as any)[name] = (modules as any)[name]; 5 | } 6 | 7 | module.exports = styled; 8 | export * from "./index"; 9 | export default styled; 10 | -------------------------------------------------------------------------------- /packages/react-css-styled/src/react-css-styled/index.cjs.ts: -------------------------------------------------------------------------------- 1 | import styled, * as modules from "./index"; 2 | 3 | for (const name in modules) { 4 | (styled as any)[name] = (modules as any)[name]; 5 | } 6 | 7 | module.exports = styled; 8 | export * from "./index"; 9 | export default styled; 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.DS_Store 3 | .DS_Store 4 | doc/ 5 | dist/ 6 | packages/*/dist/ 7 | release/ 8 | npm-debug.log* 9 | coverage/ 10 | jsdoc/ 11 | doc/ 12 | outjs/ 13 | declaration/ 14 | build/ 15 | .vscode/ 16 | rollup-plugin-visualizer/ 17 | statistics/ 18 | .scene_cache 19 | *.mp4 20 | test/ -------------------------------------------------------------------------------- /packages/preact-css-styled/src/preact-css-styled/index.cjs.ts: -------------------------------------------------------------------------------- 1 | import styled, * as modules from "./index"; 2 | 3 | for (const name in modules) { 4 | (styled as any)[name] = (modules as any)[name]; 5 | } 6 | 7 | module.exports = styled; 8 | export * from "./index"; 9 | export default styled; 10 | -------------------------------------------------------------------------------- /tsconfig.test.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "noImplicitAny": false, 6 | "types": [ 7 | "karma-chai", 8 | "mocha" 9 | ] 10 | }, 11 | "include": [ 12 | "./src/**/*.ts", 13 | "./test/**/*.ts" 14 | ] 15 | } -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.DS_Store 3 | .DS_Store 4 | doc/ 5 | template/ 6 | example/ 7 | karma.conf.js 8 | test/ 9 | mocha.opts 10 | Gruntfile.js 11 | webpack.*.js 12 | .travis.yml 13 | packages 14 | release/ 15 | demo/ 16 | coverage/ 17 | dist/report.html 18 | rollup-plugin-visualizer/ 19 | outjs/ 20 | .scene_cache 21 | *.mp3 22 | *.mp4 -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [{*.js,*.ts,*.tsx,*.jsx}] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_style = space 8 | indent_size = 4 9 | insert_final_newline = true 10 | max_line_length = 80 11 | trim_trailing_whitespace = true 12 | 13 | [{package.json,.travis.yml}] 14 | indent_style = space 15 | indent_size = 4 -------------------------------------------------------------------------------- /packages/react-css-styled/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.DS_Store 3 | .DS_Store 4 | doc/ 5 | template/ 6 | example/ 7 | karma.conf.js 8 | test/ 9 | mocha.opts 10 | Gruntfile.js 11 | webpack.*.js 12 | .travis.yml 13 | packages 14 | release/ 15 | demo/ 16 | coverage/ 17 | dist/report.html 18 | rollup-plugin-visualizer/ 19 | outjs/ 20 | .scene_cache 21 | *.mp3 22 | *.mp4 -------------------------------------------------------------------------------- /packages/preact-css-styled/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.DS_Store 3 | .DS_Store 4 | doc/ 5 | template/ 6 | example/ 7 | karma.conf.js 8 | test/ 9 | mocha.opts 10 | Gruntfile.js 11 | webpack.*.js 12 | .travis.yml 13 | packages 14 | release/ 15 | demo/ 16 | coverage/ 17 | dist/report.html 18 | rollup-plugin-visualizer/ 19 | outjs/ 20 | .scene_cache 21 | *.mp3 22 | *.mp4 -------------------------------------------------------------------------------- /packages/react-css-styled/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /scripts/custom.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | window.dataLayer = window.dataLayer || []; 3 | function gtag() { dataLayer.push(arguments); } 4 | gtag('js', new Date()); 5 | 6 | gtag('config', 'G-TRBNXHQ0ZF'); 7 | var script = document.createElement("script"); 8 | 9 | script.src = "https://www.googletagmanager.com/gtag/js?id=G-TRBNXHQ0ZF"; 10 | 11 | document.body.appendChild(script); 12 | })(); 13 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "roots": [ 3 | "", 4 | ], 5 | "transform": { 6 | "^.+\\.tsx?$": "ts-jest", 7 | }, 8 | "testMatch": ["/test/**/*.spec.ts"], 9 | // "testRegex": "spec\\.ts$", 10 | "moduleFileExtensions": [ 11 | "ts", 12 | "tsx", 13 | "js", 14 | "jsx", 15 | "json", 16 | "node", 17 | ], 18 | }; 19 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./outjs/", 4 | "esModuleInterop": false, 5 | "sourceMap": true, 6 | "module": "es2015", 7 | "target": "es5", 8 | "experimentalDecorators": true, 9 | "skipLibCheck": true, 10 | "moduleResolution": "node", 11 | "lib": [ 12 | "es2015", 13 | "dom" 14 | ], 15 | }, 16 | "include": [ 17 | "packages/css-styled/src/**/*.ts" 18 | ] 19 | } -------------------------------------------------------------------------------- /packages/css-styled/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./outjs/", 4 | "esModuleInterop": true, 5 | "sourceMap": true, 6 | "module": "es2015", 7 | "target": "es5", 8 | "experimentalDecorators": true, 9 | "skipLibCheck": true, 10 | "moduleResolution": "node", 11 | "lib": [ 12 | "es2015", 13 | "dom" 14 | ], 15 | }, 16 | "include": [ 17 | "./src/**/*.ts" 18 | ] 19 | } -------------------------------------------------------------------------------- /packages/croact-css-styled/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./outjs/", 4 | "esModuleInterop": false, 5 | "sourceMap": true, 6 | "module": "es2015", 7 | "target": "es5", 8 | "experimentalDecorators": true, 9 | "skipLibCheck": true, 10 | "moduleResolution": "node", 11 | "lib": [ 12 | "es2015", 13 | "dom" 14 | ], 15 | }, 16 | "include": [ 17 | "./src/**/*.ts" 18 | ] 19 | } -------------------------------------------------------------------------------- /packages/react-css-styled/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /packages/react-css-styled/tsconfig.declaration.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "allowJs": false, 5 | "noEmit": false, 6 | "isolatedModules": false, 7 | "removeComments": true, 8 | "declaration": true, 9 | "emitDeclarationOnly": true, 10 | "declarationDir": "declaration" 11 | }, 12 | "include": [ 13 | "./src/react-css-styled/*" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /packages/preact-css-styled/tsconfig.declaration.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "allowJs": false, 5 | "noEmit": false, 6 | "isolatedModules": false, 7 | "removeComments": true, 8 | "declaration": true, 9 | "emitDeclarationOnly": true, 10 | "declarationDir": "declaration" 11 | }, 12 | "include": [ 13 | "./src/preact-css-styled/*" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /packages/react-css-styled/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: https://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /packages/preact-css-styled/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "preserve" 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /packages/react-css-styled/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "preserve" 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /packages/react-css-styled/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 40vmin; 8 | pointer-events: none; 9 | } 10 | 11 | .App-header { 12 | background-color: #282c34; 13 | min-height: 100vh; 14 | display: flex; 15 | flex-direction: column; 16 | align-items: center; 17 | justify-content: center; 18 | font-size: calc(10px + 2vmin); 19 | color: white; 20 | } 21 | 22 | .App-link { 23 | color: #61dafb; 24 | } 25 | 26 | @keyframes App-logo-spin { 27 | from { 28 | transform: rotate(0deg); 29 | } 30 | to { 31 | transform: rotate(360deg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/preact-css-styled/src/demo/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 40vmin; 8 | pointer-events: none; 9 | } 10 | 11 | .App-header { 12 | background-color: #282c34; 13 | min-height: 100vh; 14 | display: flex; 15 | flex-direction: column; 16 | align-items: center; 17 | justify-content: center; 18 | font-size: calc(10px + 2vmin); 19 | color: white; 20 | } 21 | 22 | .App-link { 23 | color: #61dafb; 24 | } 25 | 26 | @keyframes App-logo-spin { 27 | from { 28 | transform: rotate(0deg); 29 | } 30 | to { 31 | transform: rotate(360deg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/preact-css-styled/rollup.config.demo.js: -------------------------------------------------------------------------------- 1 | import builder from "@daybrush/builder"; 2 | import css from "rollup-plugin-css-bundle"; 3 | const preact = require("rollup-plugin-preact"); 4 | 5 | export default builder({ 6 | input: "./src/demo/index.tsx", 7 | tsconfig: "./tsconfig.build.json", 8 | sourcemap: false, 9 | format: "umd", 10 | output: "./public/dist/index.js", 11 | name: "app", 12 | exports: "named", 13 | plugins: [ 14 | css({ output: "./public/dist/index.css" }), 15 | preact({ 16 | noPropTypes: true, 17 | noEnv: true, 18 | noReactIs: true, 19 | resolvePreactCompat: true, 20 | }), 21 | ], 22 | }); 23 | -------------------------------------------------------------------------------- /packages/css-styled/src/types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @typedef 3 | * @property - Unique class name of the corresponding css 4 | * @property - Insert css into the document owned by the target element. 5 | */ 6 | export interface StyledInjector { 7 | className: string; 8 | inject(el: HTMLElement | SVGElement, options?: Partial): InjectResult; 9 | } 10 | /** 11 | * @typedef 12 | * @property - Whether to put the unique class name of css or show it as original 13 | * @property - csp nonce id 14 | */ 15 | export interface InjectOptions { 16 | original: boolean; 17 | nonce: string; 18 | } 19 | 20 | /** 21 | * @typedef 22 | * @property - Remove css. 23 | */ 24 | export interface InjectResult { 25 | destroy(): void; 26 | } 27 | -------------------------------------------------------------------------------- /packages/react-css-styled/rollup.config.js: -------------------------------------------------------------------------------- 1 | 2 | import builder from "@daybrush/builder"; 3 | 4 | 5 | const external = { 6 | "react": "React", 7 | "react-dom": "ReactDOM", 8 | "@daybrush/utils": "utils", 9 | "css-styled": "css-styled", 10 | }; 11 | export default builder([ 12 | { 13 | tsconfig: "tsconfig.build.json", 14 | input: "src/react-css-styled/index.ts", 15 | output: "./dist/styled.esm.js", 16 | exports: "named", 17 | format: "es", 18 | external, 19 | }, 20 | { 21 | tsconfig: "tsconfig.build.json", 22 | input: "src/react-css-styled/index.cjs.ts", 23 | output: "./dist/styled.cjs.js", 24 | exports: "named", 25 | format: "cjs", 26 | external, 27 | }, 28 | ]); 29 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | 2 | import builder from "@daybrush/builder"; 3 | 4 | const defaultConfig = { 5 | name: "styled", 6 | input: "src/styled.ts", 7 | exports: "default", 8 | commonjs: true, 9 | } 10 | export default builder([ 11 | { 12 | ...defaultConfig, 13 | output: "./dist/styled.js", 14 | resolve: true, 15 | }, 16 | { 17 | ...defaultConfig, 18 | output: "./dist/styled.min.js", 19 | resolve: true, 20 | uglify: true, 21 | }, 22 | { 23 | ...defaultConfig, 24 | output: "./dist/styled.esm.js", 25 | format: "es", 26 | }, 27 | { 28 | ...defaultConfig, 29 | input: "src/index.cjs.ts", 30 | output: "./dist/styled.cjs.js", 31 | format: "cjs", 32 | exports: "named", 33 | }, 34 | ]); 35 | -------------------------------------------------------------------------------- /packages/croact-css-styled/src/styled.d.ts: -------------------------------------------------------------------------------- 1 | import { Component } from "croact"; 2 | import { IObject } from "@daybrush/utils"; 3 | import { StyledInjector, InjectResult } from "css-styled"; 4 | 5 | export declare class StyledElement extends Component> { 6 | injector: StyledInjector; 7 | element: T; 8 | injectResult: InjectResult | null; 9 | tag: string; 10 | render(): any; 11 | componentDidMount(): void; 12 | componentWillUnmount(): void; 13 | getElement(): T; 14 | } 15 | 16 | 17 | export default function styled(tag: string, css: string): typeof StyledElement & (new (...args: any[]) => StyledElement); 18 | export function styled(tag: string, css: string): (...args: any[]) => any; 19 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmClient": "yarn", 3 | "useWorkspaces": true, 4 | "packages": [ 5 | "packages/*" 6 | ], 7 | "version": "independent", 8 | "lernaHelperOptions": { 9 | "deployFileMap": [ 10 | { 11 | "basePath": "packages/css-styled/dist", 12 | "dists": [ 13 | "demo/release/{{version}}/dist", 14 | "demo/release/latest/dist" 15 | ] 16 | }, 17 | { 18 | "basePath": "doc", 19 | "dists": [ 20 | "demo/release/{{version}}/doc", 21 | "demo/release/latest/doc" 22 | ] 23 | } 24 | ], 25 | "beforeReleaseScripts": [ 26 | "npm run demo:build", 27 | "npm run deploy" 28 | ] 29 | } 30 | } -------------------------------------------------------------------------------- /packages/preact-css-styled/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Preact App 6 | 7 | 8 | 9 | 10 |
11 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": [ 4 | "tslint:recommended" 5 | ], 6 | "rules": { 7 | "jsdoc-format": false, 8 | "forin": false, 9 | "no-console": false, 10 | "no-any": false, 11 | "interface-name": false, 12 | "indent": [ 13 | true, 14 | "spaces", 15 | 4 16 | ], 17 | "ordered-imports": false, 18 | "object-literal-sort-keys": false, 19 | "no-unused-expression": false, 20 | "arrow-parens": [ 21 | true, 22 | "ban-single-arg-parens" 23 | ], 24 | "max-line-length": [ 25 | true, 26 | { 27 | "limit": 120, 28 | "ignore-pattern": "(\\* @)|//" 29 | } 30 | ], 31 | "trailing-comma": [ 32 | true, 33 | { 34 | "multiline": { 35 | "objects": "always", 36 | "arrays": "always", 37 | "functions": "always", 38 | "typeLiterals": "ignore" 39 | }, 40 | "esSpecCompliant": true 41 | } 42 | ] 43 | } 44 | } -------------------------------------------------------------------------------- /packages/preact-css-styled/src/preact-css-styled/styled.d.ts: -------------------------------------------------------------------------------- 1 | import { Component, version } from "preact"; 2 | import { IObject } from "@daybrush/utils"; 3 | import { StyledInjector, InjectResult } from "css-styled"; 4 | export declare class StyledElement extends Component> { 5 | injector: StyledInjector; 6 | element: T; 7 | injectResult: InjectResult | null; 8 | tag: string; 9 | render(): any; 10 | componentDidMount(): void; 11 | componentWillUnmount(): void; 12 | getElement(): T; 13 | } 14 | 15 | 16 | export default function styled(tag: string, css: string): typeof StyledElement & (new (...args: any[]) => StyledElement); 17 | export function styled(tag: string, css: string): typeof StyledElement & (new (...args: any[]) => StyledElement); 18 | -------------------------------------------------------------------------------- /packages/croact-css-styled/rollup.config.js: -------------------------------------------------------------------------------- 1 | 2 | import builder from "@daybrush/builder"; 3 | import reactCompat from "rollup-plugin-react-compat"; 4 | 5 | const external = { 6 | "croact": "croact", 7 | "@daybrush/utils": "utils", 8 | "css-styled": "css-styled", 9 | "framework-utils": "framework-utils" 10 | }; 11 | 12 | 13 | const reactPlugin = reactCompat({ 14 | useCroact: true, 15 | }) 16 | 17 | 18 | 19 | export default builder([ 20 | { 21 | sourcemap: false, 22 | input: "src/index.esm.ts", 23 | output: "./dist/styled.esm.js", 24 | exports: "named", 25 | format: "es", 26 | plugins: [reactPlugin], 27 | external, 28 | }, 29 | { 30 | sourcemap: false, 31 | input: "src/index.cjs.ts", 32 | output: "./dist/styled.cjs.js", 33 | exports: "named", 34 | plugins: [reactPlugin], 35 | format: "cjs", 36 | external, 37 | }, 38 | ]); 39 | -------------------------------------------------------------------------------- /packages/react-css-styled/README.md: -------------------------------------------------------------------------------- 1 | # react-css-styled 👋 [![npm version](https://badge.fury.io/js/react-css-styled.svg)](https://badge.fury.io/js/react-css-styled) 2 | 3 | This component is a lightweight, simple line style component. 4 | 5 | ## Installation 6 | 7 | ```sh 8 | npm install react-css-styled 9 | ``` 10 | ## How to use 11 | 12 | ```jsx 13 | import styled from "react-css-styled"; 14 | 15 | const Styler = styled("div", ` 16 | { 17 | border-radius: 50%; 18 | } 19 | * { 20 | width: 100%; 21 | height: 100%; 22 | } 23 | :host div { 24 | position: relative; 25 | } 26 | `); 27 | 28 | render() { 29 | return ( 30 |
31 |
); 32 | } 33 | ``` 34 | ## Development 35 | 36 | ### `npm start` 37 | 38 | Runs the app in the development mode.
39 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 40 | 41 | The page will reload if you make edits.
42 | You will also see any lint errors in the console. 43 | 44 | ## License 45 | 46 | ``` 47 | MIT License 48 | 49 | Copyright (c) 2019 Daybrush 50 | ``` -------------------------------------------------------------------------------- /packages/preact-css-styled/README.md: -------------------------------------------------------------------------------- 1 | # preact-css-styled 👋 [![npm version](https://badge.fury.io/js/preact-css-styled.svg)](https://badge.fury.io/js/preact-css-styled) 2 | 3 | This component is a lightweight, simple line style component. 4 | 5 | ## Installation 6 | 7 | ```sh 8 | npm install preact-css-styled 9 | ``` 10 | ## How to use 11 | 12 | ```jsx 13 | import styled from "preact-css-styled"; 14 | 15 | const Styler = styled("div", ` 16 | { 17 | border-radius: 50%; 18 | } 19 | * { 20 | width: 100%; 21 | height: 100%; 22 | } 23 | :host div { 24 | position: relative; 25 | } 26 | `); 27 | 28 | render() { 29 | return ( 30 |
31 |
); 32 | } 33 | ``` 34 | ## Development 35 | 36 | ### `npm start` 37 | 38 | Runs the app in the development mode.
39 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 40 | 41 | The page will reload if you make edits.
42 | You will also see any lint errors in the console. 43 | 44 | ## License 45 | 46 | ``` 47 | MIT License 48 | 49 | Copyright (c) 2019 Daybrush 50 | ``` -------------------------------------------------------------------------------- /packages/css-styled/rollup.config.js: -------------------------------------------------------------------------------- 1 | 2 | import builder from "@daybrush/builder"; 3 | 4 | const defaultConfig = { 5 | name: "styled", 6 | input: "src/styled.ts", 7 | exports: "default", 8 | commonjs: true, 9 | } 10 | export default builder([ 11 | { 12 | ...defaultConfig, 13 | output: "./dist/styled.js", 14 | resolve: true, 15 | }, 16 | { 17 | ...defaultConfig, 18 | output: "./dist/styled.min.js", 19 | resolve: true, 20 | uglify: true, 21 | }, 22 | { 23 | ...defaultConfig, 24 | output: "./dist/styled.esm.js", 25 | format: "es", 26 | resolve: true, 27 | external: { 28 | "@daybrush/utils": "@daybrush/utils", 29 | }, 30 | }, 31 | { 32 | ...defaultConfig, 33 | input: "src/index.cjs.ts", 34 | output: "./dist/styled.cjs.js", 35 | format: "cjs", 36 | exports: "named", 37 | resolve: true, 38 | external: { 39 | "@daybrush/utils": "@daybrush/utils", 40 | }, 41 | }, 42 | ]); 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Daybrush 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/react-css-styled/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Daybrush 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/preact-css-styled/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Daybrush 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/preact-css-styled/rollup.config.js: -------------------------------------------------------------------------------- 1 | 2 | import builder from "@daybrush/builder"; 3 | const preact = require("rollup-plugin-preact"); 4 | 5 | 6 | const defaultOptions = { 7 | tsconfig: "tsconfig.build.json", 8 | external: { 9 | "preact": "preact", 10 | "preact/compat": "preact/compat", 11 | "@daybrush/utils": "@daybrush/utils", 12 | "css-styled": "css-styled", 13 | "framework-utils": "framework-utils", 14 | }, 15 | exports: "named", 16 | plugins: [ 17 | preact({ 18 | noPropTypes: true, 19 | noEnv: true, 20 | noReactIs: true, 21 | usePreactX: true, 22 | // resolvePreactCompat: true, 23 | }), 24 | ], 25 | sourcemap: false, 26 | }; 27 | 28 | export default builder([ 29 | { 30 | ...defaultOptions, 31 | input: "src/preact-css-styled/index.esm.ts", 32 | output: "./dist/styled.esm.js", 33 | exports: "named", 34 | format: "es", 35 | }, 36 | { 37 | ...defaultOptions, 38 | input: "src/preact-css-styled/index.cjs.ts", 39 | output: "./dist/styled.cjs.js", 40 | exports: "named", 41 | format: "cjs", 42 | }, 43 | ]); 44 | -------------------------------------------------------------------------------- /jsdoc.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "plugins": [], 4 | "recurseDepth": 10, 5 | "opts": { 6 | "template": "./node_modules/daybrush-jsdoc-template", 7 | "destination": "./doc/" 8 | }, 9 | "source": { 10 | "include": ["./src", "README.md"], 11 | "includePattern": "(.+\\.js(doc|x)?|.+\\.ts(doc|x)?)$", 12 | "excludePattern": "(^|\\/|\\\\)_" 13 | }, 14 | "sourceType": "module", 15 | "tags": { 16 | "allowUnknownTags": true, 17 | "dictionaries": ["jsdoc","closure"] 18 | }, 19 | "templates": { 20 | "cleverLinks": false, 21 | "monospaceLinks": false, 22 | "default": { 23 | "staticFiles": { 24 | "include": [ 25 | "./static" 26 | ] 27 | } 28 | } 29 | }, 30 | "linkMap": { 31 | "IObject": "http://daybrush.com/utils/release/latest/doc/global.html#ObjectInterface" 32 | }, 33 | "docdash": { 34 | "menu": { 35 | "Github repo": { 36 | "href": "https://github.com/daybrush/css-styled", 37 | "target": "_blank", 38 | "class": "menu-item", 39 | "id": "repository" 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /packages/css-styled/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "css-styled", 3 | "version": "1.0.8", 4 | "description": "This component is a lightweight, simple line style component.", 5 | "main": "./dist/styled.cjs.js", 6 | "module": "./dist/styled.esm.js", 7 | "sideEffects": false, 8 | "types": "declaration/styled.d.ts", 9 | "scripts": { 10 | "start": "rollup -c -w", 11 | "build": "rollup -c && npm run declaration && print-sizes ./dist", 12 | "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/daybrush/css-styled.git" 17 | }, 18 | "author": "Daybrush", 19 | "license": "MIT", 20 | "bugs": { 21 | "url": "https://github.com/daybrush/css-styled/issues" 22 | }, 23 | "files": [ 24 | "./*", 25 | "src/*", 26 | "dist/*", 27 | "declaration/*", 28 | "README.md" 29 | ], 30 | "homepage": "https://github.com/daybrush/css-styled#readme", 31 | "dependencies": { 32 | "@daybrush/utils": "^1.13.0" 33 | }, 34 | "devDependencies": { 35 | "@daybrush/builder": "^0.1.2", 36 | "jest": "^26.4.2", 37 | "print-coveralls": "^1.2.2", 38 | "print-sizes": "^0.2.0", 39 | "typescript": "^4.5.0 <4.6.0", 40 | "string-hash": "^1.1.3" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /packages/react-css-styled/src/react-css-styled/StyledElement.tsx: -------------------------------------------------------------------------------- 1 | import { Component, createElement, version } from "react"; 2 | import { IObject } from "@daybrush/utils"; 3 | import { StyledInjector, InjectResult } from "css-styled"; 4 | import { ref } from "framework-utils"; 5 | 6 | export class StyledElement extends Component> { 7 | public injector!: StyledInjector; 8 | public element!: T; 9 | public injectResult: InjectResult | null = null; 10 | public tag: string = "div"; 11 | public render(): any { 12 | const { 13 | className = "", 14 | cspNonce, 15 | portalContainer, 16 | ...attributes 17 | } = this.props; 18 | const cssId = this.injector!.className; 19 | const Tag = this.tag; 20 | let portalAttributes: Record = {}; 21 | 22 | if ((version || "").indexOf("simple") > -1 && portalContainer) { 23 | portalAttributes = { portalContainer }; 24 | } 25 | 26 | return createElement(Tag, { 27 | "ref": ref(this, "element"), 28 | "data-styled-id": cssId, 29 | "className": `${className} ${cssId}`, 30 | ...portalAttributes, 31 | ...attributes, 32 | }); 33 | } 34 | public componentDidMount() { 35 | this.injectResult = this.injector!.inject(this.element!, { 36 | nonce: this.props.cspNonce, 37 | }); 38 | } 39 | public componentWillUnmount() { 40 | this.injectResult!.destroy(); 41 | this.injectResult = null; 42 | } 43 | public getElement() { 44 | return this.element; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/react-css-styled/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 22 | React App 23 | 24 | 25 | 26 |
27 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /packages/croact-css-styled/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "croact-css-styled", 3 | "version": "1.1.9", 4 | "description": "This component is a lightweight, simple line style component for react-compat", 5 | "main": "./dist/styled.cjs.js", 6 | "module": "./dist/styled.esm.js", 7 | "sideEffects": false, 8 | "types": "declaration/index.d.ts", 9 | "keywords": [ 10 | "styled", 11 | "inline-style", 12 | "styled-components", 13 | "style", 14 | "css", 15 | "styler" 16 | ], 17 | "files": [ 18 | "./*", 19 | "src/*", 20 | "dist/*", 21 | "declaration/*", 22 | "README.md" 23 | ], 24 | "scripts": { 25 | "build": "rollup -c && npm run declaration&& npm run declaration:cp && print-sizes ./dist", 26 | "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json", 27 | "declaration:cp": "cp src/styled.d.ts declaration/styled.d.ts" 28 | }, 29 | "repository": { 30 | "type": "git", 31 | "url": "git+https://github.com/daybrush/css-styled.git" 32 | }, 33 | "author": "Daybrush", 34 | "bugs": { 35 | "url": "https://github.com/daybrush/css-styled/issues" 36 | }, 37 | "homepage": "https://github.com/daybrush/css-styled#readme", 38 | "license": "MIT", 39 | "dependencies": { 40 | "@daybrush/utils": "^1.13.0", 41 | "css-styled": "~1.0.8", 42 | "framework-utils": "^1.1.0" 43 | }, 44 | "devDependencies": { 45 | "@daybrush/builder": "^0.1.2", 46 | "@types/react": "^16.0.0", 47 | "croact": "^1.0.3", 48 | "print-sizes": "^0.2.0", 49 | "react-css-styled": "~1.1.9", 50 | "rollup": "^1.29.0", 51 | "rollup-plugin-react-compat": "^0.1.1", 52 | "tslint": "^5.20.1", 53 | "typescript": "^3.7.4" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /packages/css-styled/src/styled.ts: -------------------------------------------------------------------------------- 1 | import { getHash, injectStyle, getShadowRoot } from "./utils"; 2 | import { StyledInjector, InjectOptions } from "./types"; 3 | 4 | /** 5 | * Create an styled object that can be defined and inserted into the css. 6 | * @param - css styles 7 | */ 8 | function styled(css: string): StyledInjector { 9 | const injectClassName = "rCS" + getHash(css); 10 | 11 | return { 12 | className: injectClassName, 13 | inject(el: HTMLElement | SVGElement, options: Partial = {}) { 14 | const shadowRoot = getShadowRoot(el); 15 | let styleElement = (shadowRoot || el.ownerDocument || document).querySelector(`style[data-styled-id="${injectClassName}"]`); 16 | 17 | if (!styleElement) { 18 | styleElement = injectStyle(injectClassName, css, options, el, shadowRoot); 19 | } else { 20 | const count = parseFloat(styleElement.getAttribute("data-styled-count")) || 0; 21 | styleElement.setAttribute("data-styled-count", `${count + 1}`); 22 | } 23 | return { 24 | destroy() { 25 | const injectCount = parseFloat(styleElement.getAttribute("data-styled-count")) || 0; 26 | 27 | if (injectCount <= 1) { 28 | if (styleElement.remove) { 29 | styleElement.remove(); 30 | } else { 31 | styleElement.parentNode?.removeChild(styleElement); 32 | } 33 | styleElement = null; 34 | } else { 35 | styleElement.setAttribute("data-styled-count", `${injectCount - 1}`); 36 | } 37 | }, 38 | }; 39 | }, 40 | }; 41 | } 42 | 43 | export * from "./types"; 44 | export default styled; 45 | -------------------------------------------------------------------------------- /packages/react-css-styled/src/react-css-styled/styled.tsx: -------------------------------------------------------------------------------- 1 | import cssStyled from "css-styled"; 2 | import { 3 | createElement, forwardRef, 4 | ForwardRefExoticComponent, 5 | PropsWithoutRef, 6 | useEffect, 7 | useImperativeHandle, 8 | useRef, 9 | } from "react"; 10 | import { StyledElement } from "./StyledElement"; 11 | 12 | export default function defaultStyled( 13 | tag: string, css: string): typeof StyledElement & (new (...args: any[]) => StyledElement) { 14 | const injector = cssStyled(css); 15 | 16 | return class Styled extends StyledElement { 17 | public injector = injector; 18 | public tag = tag; 19 | }; 20 | } 21 | 22 | 23 | export function styled< 24 | Target extends HTMLElement | SVGElement = HTMLElement, 25 | Props extends Record = Record, 26 | >( 27 | Tag: string, 28 | css: string 29 | ): ForwardRefExoticComponent & React.RefAttributes> { 30 | const injector = cssStyled(css); 31 | const cssId = injector!.className; 32 | 33 | return forwardRef((props, ref) => { 34 | const { 35 | className = "", 36 | cspNonce, 37 | ...attributes 38 | } = props; 39 | const targetRef = useRef(); 40 | 41 | useImperativeHandle(ref, () => targetRef.current!, []); 42 | useEffect(() => { 43 | const injectResult = injector.inject(targetRef.current!, { 44 | nonce: props.cspNonce, 45 | }); 46 | 47 | return () => { 48 | injectResult.destroy(); 49 | }; 50 | }, []); 51 | return createElement(Tag, { 52 | "ref": targetRef, 53 | "data-styled-id": cssId, 54 | "className": `${className} ${cssId}`, 55 | ...attributes, 56 | }); 57 | }); 58 | } 59 | -------------------------------------------------------------------------------- /packages/react-css-styled/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-css-styled", 3 | "version": "1.1.9", 4 | "description": "This component is a lightweight, simple line style component for react.", 5 | "main": "./dist/styled.cjs.js", 6 | "module": "./dist/styled.esm.js", 7 | "sideEffects": false, 8 | "types": "declaration/index.d.ts", 9 | "keywords": [ 10 | "styled", 11 | "inline-style", 12 | "styled-components", 13 | "style", 14 | "css", 15 | "styler" 16 | ], 17 | "files": [ 18 | "./*", 19 | "src/*", 20 | "dist/*", 21 | "declaration/*", 22 | "README.md" 23 | ], 24 | "dependencies": { 25 | "css-styled": "~1.0.8", 26 | "framework-utils": "^1.1.0" 27 | }, 28 | "devDependencies": { 29 | "@daybrush/builder": "^0.1.2", 30 | "@types/node": "12.0.8", 31 | "@types/react": "16.8.20", 32 | "@types/react-dom": "16.8.4", 33 | "@types/string-hash": "^1.1.1", 34 | "print-sizes": "^0.2.0", 35 | "react": "^16.8.6", 36 | "react-dom": "^16.8.6", 37 | "react-scripts": "^3.0.1", 38 | "string-hash": "^1.1.3", 39 | "typescript": "^3.5.2" 40 | }, 41 | "scripts": { 42 | "start": "SKIP_PREFLIGHT_CHECK=true react-scripts start", 43 | "build": "rollup -c && npm run declaration && print-sizes ./dist", 44 | "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json" 45 | }, 46 | "author": "Daybrush", 47 | "license": "MIT", 48 | "repository": { 49 | "type": "git", 50 | "url": "https://github.com/daybrush/css-styled/tree/master/packages/react-css-styled" 51 | }, 52 | "bugs": { 53 | "url": "https://github.com/daybrush/css-styled/issues" 54 | }, 55 | "homepage": "https://github.com/daybrush/css-styled#readme", 56 | "eslintConfig": { 57 | "extends": "react-app" 58 | }, 59 | "browserslist": { 60 | "production": [ 61 | ">0.2%", 62 | "not dead", 63 | "not op_mini all" 64 | ], 65 | "development": [ 66 | "last 1 chrome version", 67 | "last 1 firefox version", 68 | "last 1 safari version" 69 | ] 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "css-styled-root", 3 | "private": true, 4 | "version": "1.0.1", 5 | "description": "This component is a lightweight, simple line style component.", 6 | "scripts": { 7 | "build": "npm run build --prefix ./packages/css-styled", 8 | "packages:update": "lerna-helper version", 9 | "packages:build": "lerna run build", 10 | "packages:publish": "lerna-helper publish --commit 'chore: publish packages'", 11 | "demo:build": "npm run packages:build && npm run doc", 12 | "changelog": "lerna-helper changelog --type all --base css-styled", 13 | "changelog:root": "lerna-helper changelog --type root --base css-styled", 14 | "doc": "rm -rf ./doc && jsdoc -c jsdoc.json", 15 | "predeploy": "lerna-helper deploy --base css-styled --pre", 16 | "deploy": "lerna-helper deploy --base css-styled", 17 | "release": "lerna-helper release --base css-styled" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/daybrush/css-styled.git" 22 | }, 23 | "author": "Daybrush", 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/daybrush/css-styled/issues" 27 | }, 28 | "homepage": "https://github.com/daybrush/css-styled#readme", 29 | "devDependencies": { 30 | "@daybrush/jsdoc": "^0.4.5", 31 | "@daybrush/release": "^0.7.0", 32 | "cpx": "1.5.0", 33 | "daybrush-jsdoc-template": "^1.9.0", 34 | "gh-pages": "^2.0.1", 35 | "intercept-stdout": "0.1.2", 36 | "lerna": "^4.0.0", 37 | "lerna-changelog": "2.2.0", 38 | "typescript": "^4.5.0 <4.6.0" 39 | }, 40 | "workspaces": { 41 | "packages": [ 42 | "packages/*", 43 | "packages/ngx-infinite-viewer/projects/ngx-infinite-viewer" 44 | ] 45 | }, 46 | "resolutions": { 47 | "@daybrush/utils": "^1.13.0", 48 | "typescript": "^4.5.0 <4.6.0", 49 | "tslib": "^2.3.0" 50 | }, 51 | "overrides": { 52 | "@daybrush/utils": "^1.13.0", 53 | "typescript": "^4.5.0 <4.6.0", 54 | "tslib": "^2.3.0" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /packages/css-styled/src/utils.ts: -------------------------------------------------------------------------------- 1 | import stringHash from "string-hash"; 2 | import { getDocument, splitComma } from "@daybrush/utils"; 3 | import { InjectOptions } from "./types"; 4 | 5 | export function getHash(str: string) { 6 | return stringHash(str).toString(36); 7 | } 8 | export function getShadowRoot(parentElement: HTMLElement | SVGElement) { 9 | if (parentElement && parentElement.getRootNode) { 10 | const rootNode = parentElement.getRootNode(); 11 | 12 | if (rootNode.nodeType === 11) { 13 | return rootNode as ShadowRoot; 14 | } 15 | } 16 | return; 17 | } 18 | export function replaceStyle(className: string, css: string, options: Partial) { 19 | if (options.original) { 20 | return css; 21 | } 22 | return css.replace(/([^};{\s}][^};{]*|^\s*){/mg, (_, selector) => { 23 | const trimmedSelector = selector.trim(); 24 | return (trimmedSelector ? splitComma(trimmedSelector) : [""]).map(subSelector => { 25 | const trimmedSubSelector = subSelector.trim(); 26 | if (trimmedSubSelector.indexOf("@") === 0) { 27 | return trimmedSubSelector; 28 | } else if (trimmedSubSelector.indexOf(":global") > -1) { 29 | return trimmedSubSelector.replace(/\:global/g, ""); 30 | } else if (trimmedSubSelector.indexOf(":host") > -1) { 31 | return `${trimmedSubSelector.replace(/\:host/g, `.${className}`)}`; 32 | } else if (trimmedSubSelector) { 33 | return `.${className} ${trimmedSubSelector}`; 34 | } else { 35 | return `.${className}`; 36 | } 37 | }).join(", ") + " {"; 38 | }); 39 | } 40 | export function injectStyle(className: string, css: string, options: Partial, el: Node, shadowRoot?: Node) { 41 | const doc = getDocument(el); 42 | const style = doc.createElement("style"); 43 | 44 | style.setAttribute("type", "text/css"); 45 | style.setAttribute("data-styled-id", className); 46 | style.setAttribute("data-styled-count", "1"); 47 | 48 | if (options.nonce) { 49 | style.setAttribute("nonce", options.nonce); 50 | } 51 | style.innerHTML = replaceStyle(className, css, options); 52 | 53 | (shadowRoot || doc.head || doc.body).appendChild(style); 54 | return style; 55 | } 56 | -------------------------------------------------------------------------------- /packages/preact-css-styled/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "preact-css-styled", 3 | "version": "1.1.9", 4 | "description": "This component is a lightweight, simple line style component.", 5 | "main": "./dist/styled.cjs.js", 6 | "module": "./dist/styled.esm.js", 7 | "sideEffects": false, 8 | "types": "declaration/index.d.ts", 9 | "keywords": [ 10 | "styled", 11 | "inline-style", 12 | "styled-components", 13 | "style", 14 | "css", 15 | "styler", 16 | "preact" 17 | ], 18 | "files": [ 19 | "./*", 20 | "src/*", 21 | "dist/*", 22 | "declaration/*", 23 | "README.md" 24 | ], 25 | "dependencies": { 26 | "css-styled": "~1.0.8", 27 | "framework-utils": "^1.1.0" 28 | }, 29 | "devDependencies": { 30 | "@daybrush/builder": "^0.1.2", 31 | "preact": "^10.0.0", 32 | "print-sizes": "^0.2.0", 33 | "react-css-styled": "~1.1.9", 34 | "rollup": "^1.27.0", 35 | "rollup-plugin-css-bundle": "^1.0.4", 36 | "rollup-plugin-preact": "^0.5.2", 37 | "tslint": "^5.18.0", 38 | "typescript": "^3.5.2" 39 | }, 40 | "scripts": { 41 | "start": "open ./public/index.html && rollup -c rollup.config.demo.js -w", 42 | "build": "rollup -c && npm run declaration && npm run declaration:cp && print-sizes ./dist ", 43 | "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json", 44 | "declaration:cp": "cp src/preact-css-styled/styled.d.ts declaration/styled.d.ts" 45 | }, 46 | "author": "Daybrush", 47 | "license": "MIT", 48 | "repository": { 49 | "type": "git", 50 | "url": "https://github.com/daybrush/css-styled/tree/master/packages/preact-css-styled" 51 | }, 52 | "bugs": { 53 | "url": "https://github.com/daybrush/css-styled/issues" 54 | }, 55 | "homepage": "https://github.com/daybrush/css-styled#readme", 56 | "eslintConfig": { 57 | "extends": "preact-app" 58 | }, 59 | "browserslist": { 60 | "production": [ 61 | ">0.2%", 62 | "not dead", 63 | "not op_mini all" 64 | ], 65 | "development": [ 66 | "last 1 chrome version", 67 | "last 1 firefox version", 68 | "last 1 safari version" 69 | ] 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /packages/react-css-styled/src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |

css-styled

3 |

4 | npm version 5 | 6 | 7 |

8 |

This component is a lightweight, simple line style component.

9 | 10 | ## 📄 API Documents 11 | * [API documentation](https://daybrush.com/css-styled/release/latest/doc/) 12 | 13 | ## ⚙️ Installation 14 | ### npm 15 | ```bash 16 | $ npm install css-styled 17 | ``` 18 | 19 | ### scripts 20 | 21 | ```html 22 | 23 | ``` 24 | 25 | ## 🚀 How to use 26 | ```ts 27 | 28 | import styled from "css-styled"; 29 | 30 | const cssStyled = styled(` 31 | { 32 | display: block; 33 | } 34 | .a { 35 | display: none; 36 | } 37 | `); 38 | 39 | const result = cssStyled.inject(document.body); 40 | 41 | result.destroy(); 42 | ``` 43 | 44 | ## ⭐️ Show Your Support 45 | Please give a ⭐️ if this project helped you! 46 | 47 | ## 👏 Contributing 48 | 49 | If you have any questions or requests or want to contribute to `css-styled` or other packages, please write the [issue](https://github.com/daybrush/css-styled/issues) or give me a Pull Request freely. 50 | 51 | ## 🐞 Bug Report 52 | 53 | If you find a bug, please report to us opening a new [Issue](https://github.com/daybrush/css-styled/issues) on GitHub. 54 | 55 | 56 | ## 📝 License 57 | 58 | This project is [MIT](https://github.com/daybrush/css-styled/blob/master/LICENSE) licensed. 59 | 60 | ``` 61 | MIT License 62 | 63 | Copyright (c) 2019 Daybrush 64 | 65 | Permission is hereby granted, free of charge, to any person obtaining a copy 66 | of this software and associated documentation files (the "Software"), to deal 67 | in the Software without restriction, including without limitation the rights 68 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 69 | copies of the Software, and to permit persons to whom the Software is 70 | furnished to do so, subject to the following conditions: 71 | 72 | The above copyright notice and this permission notice shall be included in all 73 | copies or substantial portions of the Software. 74 | 75 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 76 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 77 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 78 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 79 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 80 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 81 | SOFTWARE. 82 | ``` -------------------------------------------------------------------------------- /packages/css-styled/README.md: -------------------------------------------------------------------------------- 1 | 2 |

css-styled

3 |

4 | npm version 5 | 6 | 7 |

8 |

This component is a lightweight, simple line style component.

9 | 10 | ## 📄 API Documents 11 | * [API documentation](https://daybrush.com/css-styled/release/latest/doc/) 12 | 13 | ## ⚙️ Installation 14 | ### npm 15 | ```bash 16 | $ npm install css-styled 17 | ``` 18 | 19 | ### scripts 20 | 21 | ```html 22 | 23 | ``` 24 | 25 | ## 🚀 How to use 26 | ```ts 27 | 28 | import styled from "css-styled"; 29 | 30 | const cssStyled = styled(` 31 | { 32 | display: block; 33 | } 34 | .a { 35 | display: none; 36 | } 37 | `); 38 | 39 | const result = cssStyled.inject(document.body); 40 | 41 | result.destroy(); 42 | ``` 43 | 44 | ## ⭐️ Show Your Support 45 | Please give a ⭐️ if this project helped you! 46 | 47 | ## 👏 Contributing 48 | 49 | If you have any questions or requests or want to contribute to `css-styled` or other packages, please write the [issue](https://github.com/daybrush/css-styled/issues) or give me a Pull Request freely. 50 | 51 | ## 🐞 Bug Report 52 | 53 | If you find a bug, please report to us opening a new [Issue](https://github.com/daybrush/css-styled/issues) on GitHub. 54 | 55 | 56 | ## 📝 License 57 | 58 | This project is [MIT](https://github.com/daybrush/css-styled/blob/master/LICENSE) licensed. 59 | 60 | ``` 61 | MIT License 62 | 63 | Copyright (c) 2019 Daybrush 64 | 65 | Permission is hereby granted, free of charge, to any person obtaining a copy 66 | of this software and associated documentation files (the "Software"), to deal 67 | in the Software without restriction, including without limitation the rights 68 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 69 | copies of the Software, and to permit persons to whom the Software is 70 | furnished to do so, subject to the following conditions: 71 | 72 | The above copyright notice and this permission notice shall be included in all 73 | copies or substantial portions of the Software. 74 | 75 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 76 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 77 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 78 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 79 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 80 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 81 | SOFTWARE. 82 | ``` -------------------------------------------------------------------------------- /packages/react-css-styled/src/serviceWorker.ts: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.1/8 is considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | type Config = { 24 | onSuccess?: (registration: ServiceWorkerRegistration) => void; 25 | onUpdate?: (registration: ServiceWorkerRegistration) => void; 26 | }; 27 | 28 | export function register(config?: Config) { 29 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 30 | // The URL constructor is available in all browsers that support SW. 31 | const publicUrl = new URL( 32 | (process as { env: { [key: string]: string } }).env.PUBLIC_URL, 33 | window.location.href 34 | ); 35 | if (publicUrl.origin !== window.location.origin) { 36 | // Our service worker won't work if PUBLIC_URL is on a different origin 37 | // from what our page is served on. This might happen if a CDN is used to 38 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 39 | return; 40 | } 41 | 42 | window.addEventListener('load', () => { 43 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 44 | 45 | if (isLocalhost) { 46 | // This is running on localhost. Let's check if a service worker still exists or not. 47 | checkValidServiceWorker(swUrl, config); 48 | 49 | // Add some additional logging to localhost, pointing developers to the 50 | // service worker/PWA documentation. 51 | navigator.serviceWorker.ready.then(() => { 52 | console.log( 53 | 'This web app is being served cache-first by a service ' + 54 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 55 | ); 56 | }); 57 | } else { 58 | // Is not localhost. Just register service worker 59 | registerValidSW(swUrl, config); 60 | } 61 | }); 62 | } 63 | } 64 | 65 | function registerValidSW(swUrl: string, config?: Config) { 66 | navigator.serviceWorker 67 | .register(swUrl) 68 | .then(registration => { 69 | registration.onupdatefound = () => { 70 | const installingWorker = registration.installing; 71 | if (installingWorker == null) { 72 | return; 73 | } 74 | installingWorker.onstatechange = () => { 75 | if (installingWorker.state === 'installed') { 76 | if (navigator.serviceWorker.controller) { 77 | // At this point, the updated precached content has been fetched, 78 | // but the previous service worker will still serve the older 79 | // content until all client tabs are closed. 80 | console.log( 81 | 'New content is available and will be used when all ' + 82 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 83 | ); 84 | 85 | // Execute callback 86 | if (config && config.onUpdate) { 87 | config.onUpdate(registration); 88 | } 89 | } else { 90 | // At this point, everything has been precached. 91 | // It's the perfect time to display a 92 | // "Content is cached for offline use." message. 93 | console.log('Content is cached for offline use.'); 94 | 95 | // Execute callback 96 | if (config && config.onSuccess) { 97 | config.onSuccess(registration); 98 | } 99 | } 100 | } 101 | }; 102 | }; 103 | }) 104 | .catch(error => { 105 | console.error('Error during service worker registration:', error); 106 | }); 107 | } 108 | 109 | function checkValidServiceWorker(swUrl: string, config?: Config) { 110 | // Check if the service worker can be found. If it can't reload the page. 111 | fetch(swUrl) 112 | .then(response => { 113 | // Ensure service worker exists, and that we really are getting a JS file. 114 | const contentType = response.headers.get('content-type'); 115 | if ( 116 | response.status === 404 || 117 | (contentType != null && contentType.indexOf('javascript') === -1) 118 | ) { 119 | // No service worker found. Probably a different app. Reload the page. 120 | navigator.serviceWorker.ready.then(registration => { 121 | registration.unregister().then(() => { 122 | window.location.reload(); 123 | }); 124 | }); 125 | } else { 126 | // Service worker found. Proceed as normal. 127 | registerValidSW(swUrl, config); 128 | } 129 | }) 130 | .catch(() => { 131 | console.log( 132 | 'No internet connection found. App is running in offline mode.' 133 | ); 134 | }); 135 | } 136 | 137 | export function unregister() { 138 | if ('serviceWorker' in navigator) { 139 | navigator.serviceWorker.ready.then(registration => { 140 | registration.unregister(); 141 | }); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /packages/preact-css-styled/src/demo/App.tsx: -------------------------------------------------------------------------------- 1 | import { Component, h } from 'preact'; 2 | import './App.css'; 3 | import styled from '../preact-css-styled'; 4 | 5 | const css = ` 6 | { 7 | position: relative; 8 | width: 100%; 9 | font-size: 0; 10 | background: #000; 11 | display: flex; 12 | flex-direction: column; 13 | } 14 | * { 15 | box-sizing: border-box; 16 | color: #fff; 17 | } 18 | .header-area, .scroll-area { 19 | width: 100%; 20 | position: relative; 21 | display: flex; 22 | -webkit-align-items: flex-start; 23 | align-items: flex-start; 24 | } 25 | .header-area { 26 | position: relative; 27 | z-index: 10; 28 | top: 0; 29 | height: 30px; 30 | min-height: 30px; 31 | } 32 | .header-area .keyframes { 33 | padding: 0px; 34 | } 35 | .header-area .properties-area, 36 | .header-area .keyframes-area, 37 | .header-area .values-area, 38 | .header-area .keyframes-scroll-area { 39 | height: 100%; 40 | } 41 | .header-area .keyframes-scroll-area { 42 | overflow: hidden; 43 | } 44 | .header-area .property, .header-area .value, .header-area .keyframes { 45 | height: 100%; 46 | } 47 | .header-area .property { 48 | line-height: 30px; 49 | } 50 | .value .add { 51 | text-align: center; 52 | color: #fff; 53 | line-height: 30px; 54 | font-weight: bold; 55 | font-size: 20px; 56 | cursor: pointer; 57 | } 58 | .header-area .keyframes-area::-webkit-scrollbar { 59 | display: none; 60 | } 61 | .header-area .keyframe-cursor { 62 | position: absolute; 63 | border-top: 10px solid #4af; 64 | border-left: 6px solid transparent; 65 | border-right: 6px solid transparent; 66 | width: 0; 67 | height: 0; 68 | bottom: 0; 69 | top: auto; 70 | background: none; 71 | cursor: pointer; 72 | } 73 | .control-area .keyframes { 74 | padding-left: 10px; 75 | } 76 | .play-control-area { 77 | position: absolute; 78 | top: 50%; 79 | left: 50%; 80 | transform: translate(-50%, -50%); 81 | } 82 | .play-control-area .control { 83 | position: relative; 84 | display: inline-block; 85 | vertical-align: middle; 86 | color: white; 87 | margin: 0px 15px; 88 | cursor: pointer; 89 | } 90 | .play { 91 | border-left: 14px solid white; 92 | border-top: 8px solid transparent; 93 | border-bottom: 8px solid transparent; 94 | } 95 | .pause { 96 | border-left: 4px solid #fff; 97 | border-right: 4px solid #fff; 98 | width: 14px; 99 | height: 16px; 100 | } 101 | .prev { 102 | border-right: 10px solid white; 103 | border-top: 6px solid transparent; 104 | border-bottom: 6px solid transparent; 105 | } 106 | .prev:before { 107 | position: absolute; 108 | content: ""; 109 | width: 3px; 110 | height: 10px; 111 | top: 0; 112 | right: 100%; 113 | transform: translate(0, -50%); 114 | background: white; 115 | } 116 | .next { 117 | border-left: 10px solid white; 118 | border-top: 6px solid transparent; 119 | border-bottom: 6px solid transparent; 120 | } 121 | .next:before { 122 | position: absolute; 123 | content: ""; 124 | width: 3px; 125 | height: 10px; 126 | top: 0; 127 | transform: translate(0, -50%); 128 | background: white; 129 | } 130 | .keytime { 131 | position: relative; 132 | display: inline-block; 133 | height: 100%; 134 | font-size: 13px; 135 | font-weight: bold; 136 | color: #777; 137 | } 138 | .keytime:last-child { 139 | max-width: 0px; 140 | } 141 | .keytime span { 142 | position: absolute; 143 | line-height: 1; 144 | bottom: 12px; 145 | display: inline-block; 146 | transform: translate(-50%); 147 | color: #eee; 148 | } 149 | .keytime .graduation { 150 | position: absolute; 151 | bottom: 0; 152 | width: 1px; 153 | height: 10px; 154 | background: #666; 155 | transform: translate(-50%); 156 | } 157 | .keytime .graduation.half { 158 | left: 50%; 159 | height: 7px; 160 | } 161 | .keytime .graduation.quarter { 162 | left: 25%; 163 | height: 5px; 164 | } 165 | .keytime .graduation.quarter3 { 166 | left: 75%; 167 | height: 5px; 168 | } 169 | .scroll-area { 170 | position: relative; 171 | width: 100%; 172 | height: calc(100% - 60px); 173 | overflow: auto; 174 | } 175 | .properties-area, .keyframes-area, .values-area { 176 | display: inline-block; 177 | position: relative; 178 | font-size: 16px; 179 | overflow: auto; 180 | } 181 | 182 | .properties-area::-webkit-scrollbar, .keyframes-area::-webkit-scrollbar { 183 | display: none; 184 | } 185 | .properties-area { 186 | width: 30%; 187 | max-width: 200px; 188 | box-sizing: border-box; 189 | } 190 | .values-area { 191 | width: 50px; 192 | min-width: 50px; 193 | display: inline-block; 194 | border-right: 1px solid #666; 195 | box-sizing: border-box; 196 | } 197 | .value input { 198 | appearance: none; 199 | -webkit-appearance: none; 200 | outline: none; 201 | position: relative; 202 | display: block; 203 | width: 100%; 204 | height: 100%; 205 | background: transparent; 206 | color: #4af; 207 | font-weight: bold; 208 | background: none; 209 | border: 0; 210 | box-sizing: border-box; 211 | text-align: center; 212 | } 213 | .value { 214 | 215 | } 216 | .alt .value input { 217 | cursor: ew-resize; 218 | } 219 | .value[data-object="1"] input { 220 | display: none; 221 | } 222 | .properties-scroll-area { 223 | display: inline-block; 224 | min-width: 100%; 225 | } 226 | .keyframes-area { 227 | flex: 1; 228 | } 229 | .keyframes-scroll-area { 230 | position: relative; 231 | min-width: 300px; 232 | } 233 | .keyframes, .property, .value { 234 | position: relative; 235 | height: 30px; 236 | line-height: 30px; 237 | border-bottom: 1px solid #555; 238 | box-sizing: border-box; 239 | white-space: nowrap; 240 | background: rgba(90, 90, 90, 0.7); 241 | z-index: 1; 242 | } 243 | 244 | .property { 245 | padding-left: 10px; 246 | box-sizing: border-box; 247 | font-size: 13px; 248 | font-weight: bold; 249 | color: #eee; 250 | } 251 | .property .remove { 252 | position: absolute; 253 | display: inline-block; 254 | cursor: pointer; 255 | width: 18px; 256 | height: 18px; 257 | top: 0; 258 | bottom: 0; 259 | right: 10px; 260 | margin: auto; 261 | border-radius: 50%; 262 | border: 2px solid #fff; 263 | vertical-align: middle; 264 | display: none; 265 | margin-left: 10px; 266 | box-sizing: border-box; 267 | } 268 | .property .remove:before, .property .remove:after { 269 | position: absolute; 270 | content: ""; 271 | width: 8px; 272 | height: 2px; 273 | border-radius: 1px; 274 | background: #fff; 275 | top: 0; 276 | left: 0; 277 | right: 0; 278 | bottom: 0; 279 | margin: auto; 280 | } 281 | .property .remove:before { 282 | transform: rotate(45deg); 283 | } 284 | .property .remove:after { 285 | transform: rotate(-45deg); 286 | } 287 | .property:hover .remove { 288 | display: inline-block; 289 | } 290 | 291 | [data-item="1"], [data-item="1"] .add { 292 | height: 30px; 293 | line-height: 30px; 294 | } 295 | .time-area { 296 | position: absolute; 297 | top: 0; 298 | left: 10px; 299 | font-size: 13px; 300 | color: #4af; 301 | line-height: 30px; 302 | font-weight: bold; 303 | height: 100%; 304 | line-height: 30px; 305 | border: 0; 306 | background: transparent; 307 | outline: 0; 308 | } 309 | .time-area:after { 310 | content: "s"; 311 | } 312 | .property .arrow { 313 | position: relative; 314 | display: inline-block; 315 | width: 20px; 316 | height: 25px; 317 | cursor: pointer; 318 | vertical-align: middle; 319 | } 320 | .property .arrow:after { 321 | content: ""; 322 | position: absolute; 323 | top: 0; 324 | right: 0; 325 | left: 0; 326 | bottom: 0; 327 | margin: auto; 328 | width: 0; 329 | height: 0; 330 | border-top: 6px solid #eee; 331 | border-left: 4px solid transparent; 332 | border-right: 4px solid transparent; 333 | } 334 | .property[data-fold="1"] .arrow:after { 335 | border-top: 4px solid transparent; 336 | border-bottom: 4px solid transparent; 337 | border-right: 0; 338 | border-left: 6px solid #eee; 339 | } 340 | .property[data-object="0"] .arrow { 341 | display: none; 342 | } 343 | .property.fold, .keyframes.fold, .value.fold { 344 | display: none; 345 | } 346 | .property.select, .value.select, .keyframes.select { 347 | background: rgba(120, 120, 120, 0.7); 348 | } 349 | .keyframes { 350 | 351 | } 352 | .keyframe-delay { 353 | position: absolute; 354 | top: 3px; 355 | bottom: 3px; 356 | left: 0; 357 | background: #4af; 358 | opacity: 0.2; 359 | z-index: 0; 360 | } 361 | .keyframe-group { 362 | position: absolute; 363 | top: 3px; 364 | bottom: 3px; 365 | left: 0; 366 | background: #4af; 367 | opacity: 0.6; 368 | border: 1px solid rgba(0, 0, 0, 0.2); 369 | border-left-color: rgba(255, 255, 255, 0.2); 370 | border-top-color: rgba(255, 255, 255, 0.2); 371 | z-index: 0; 372 | } 373 | .keyframe-line { 374 | position: absolute; 375 | height: 8px; 376 | top: 0; 377 | bottom: 0; 378 | margin: auto; 379 | background: #666; 380 | z-index: 0; 381 | } 382 | .keyframe { 383 | position: absolute; 384 | font-size: 0px; 385 | width: 12px; 386 | height: 12px; 387 | top: 0px; 388 | bottom: 0px; 389 | margin: auto; 390 | background: #fff; 391 | border: 2px solid #383838; 392 | border-radius: 2px; 393 | box-sizing: border-box; 394 | transform: translate(-50%) rotate(45deg); 395 | z-index: 1; 396 | cursor: pointer; 397 | } 398 | .keyframe[data-no="1"] { 399 | opacity: 0.2; 400 | } 401 | .select .keyframe { 402 | border-color: #555; 403 | } 404 | .keyframe.select { 405 | background: #4af; 406 | } 407 | .keyframes-container, .line-area { 408 | position: relative; 409 | width: calc(100% - 30px); 410 | left: 15px; 411 | height: 100%; 412 | } 413 | .line-area { 414 | position: absolute; 415 | top: 0; 416 | z-index: 0; 417 | } 418 | .keyframe-cursor { 419 | position: absolute; 420 | top: 0; 421 | z-index: 1; 422 | background: #4af; 423 | width: 1px; 424 | height: 100%; 425 | left: 15px; 426 | transform: translate(-50%); 427 | } 428 | .scroll-aare .keyframe-cursor { 429 | pointer-events: none; 430 | } 431 | .division-line { 432 | position: absolute; 433 | background: #333; 434 | width: 1px; 435 | height: 100%; 436 | transform: translate(-50%); 437 | }`; 438 | 439 | const Styler = styled("div", css); 440 | 441 | const App = () => { 442 | return ( 443 |
444 | 445 |
446 | ); 447 | } 448 | 449 | export default App; 450 | -------------------------------------------------------------------------------- /packages/react-css-styled/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from './logo.svg'; 3 | import './App.css'; 4 | import { styled } from './react-css-styled'; 5 | import { ref } from 'framework-utils'; 6 | 7 | const css = ` 8 | { 9 | position: relative; 10 | width: 100%; 11 | font-size: 0; 12 | background: #000; 13 | display: flex; 14 | flex-direction: column; 15 | } 16 | * { 17 | box-sizing: border-box; 18 | color: #fff; 19 | } 20 | .header-area, .scroll-area { 21 | width: 100%; 22 | position: relative; 23 | display: flex; 24 | -webkit-align-items: flex-start; 25 | align-items: flex-start; 26 | } 27 | .header-area { 28 | position: relative; 29 | z-index: 10; 30 | top: 0; 31 | height: 30px; 32 | min-height: 30px; 33 | } 34 | .header-area .keyframes { 35 | padding: 0px; 36 | } 37 | .header-area .properties-area, 38 | .header-area .keyframes-area, 39 | .header-area .values-area, 40 | .header-area .keyframes-scroll-area { 41 | height: 100%; 42 | } 43 | .header-area .keyframes-scroll-area { 44 | overflow: hidden; 45 | } 46 | .header-area .property, .header-area .value, .header-area .keyframes { 47 | height: 100%; 48 | } 49 | .header-area .property { 50 | line-height: 30px; 51 | } 52 | .value .add { 53 | text-align: center; 54 | color: #fff; 55 | line-height: 30px; 56 | font-weight: bold; 57 | font-size: 20px; 58 | cursor: pointer; 59 | } 60 | .header-area .keyframes-area::-webkit-scrollbar { 61 | display: none; 62 | } 63 | .header-area .keyframe-cursor { 64 | position: absolute; 65 | border-top: 10px solid #4af; 66 | border-left: 6px solid transparent; 67 | border-right: 6px solid transparent; 68 | width: 0; 69 | height: 0; 70 | bottom: 0; 71 | top: auto; 72 | background: none; 73 | cursor: pointer; 74 | } 75 | .control-area .keyframes { 76 | padding-left: 10px; 77 | } 78 | .play-control-area { 79 | position: absolute; 80 | top: 50%; 81 | left: 50%; 82 | transform: translate(-50%, -50%); 83 | } 84 | .play-control-area .control { 85 | position: relative; 86 | display: inline-block; 87 | vertical-align: middle; 88 | color: white; 89 | margin: 0px 15px; 90 | cursor: pointer; 91 | } 92 | .play { 93 | border-left: 14px solid white; 94 | border-top: 8px solid transparent; 95 | border-bottom: 8px solid transparent; 96 | } 97 | .pause { 98 | border-left: 4px solid #fff; 99 | border-right: 4px solid #fff; 100 | width: 14px; 101 | height: 16px; 102 | } 103 | .prev { 104 | border-right: 10px solid white; 105 | border-top: 6px solid transparent; 106 | border-bottom: 6px solid transparent; 107 | } 108 | .prev:before { 109 | position: absolute; 110 | content: ""; 111 | width: 3px; 112 | height: 10px; 113 | top: 0; 114 | right: 100%; 115 | transform: translate(0, -50%); 116 | background: white; 117 | } 118 | .next { 119 | border-left: 10px solid white; 120 | border-top: 6px solid transparent; 121 | border-bottom: 6px solid transparent; 122 | } 123 | .next:before { 124 | position: absolute; 125 | content: ""; 126 | width: 3px; 127 | height: 10px; 128 | top: 0; 129 | transform: translate(0, -50%); 130 | background: white; 131 | } 132 | .keytime { 133 | position: relative; 134 | display: inline-block; 135 | height: 100%; 136 | font-size: 13px; 137 | font-weight: bold; 138 | color: #777; 139 | } 140 | .keytime:last-child { 141 | max-width: 0px; 142 | } 143 | .keytime span { 144 | position: absolute; 145 | line-height: 1; 146 | bottom: 12px; 147 | display: inline-block; 148 | transform: translate(-50%); 149 | color: #eee; 150 | } 151 | .keytime .graduation { 152 | position: absolute; 153 | bottom: 0; 154 | width: 1px; 155 | height: 10px; 156 | background: #666; 157 | transform: translate(-50%); 158 | } 159 | .keytime .graduation.half { 160 | left: 50%; 161 | height: 7px; 162 | } 163 | .keytime .graduation.quarter { 164 | left: 25%; 165 | height: 5px; 166 | } 167 | .keytime .graduation.quarter3 { 168 | left: 75%; 169 | height: 5px; 170 | } 171 | .scroll-area { 172 | position: relative; 173 | width: 100%; 174 | height: calc(100% - 60px); 175 | overflow: auto; 176 | } 177 | .properties-area, .keyframes-area, .values-area { 178 | display: inline-block; 179 | position: relative; 180 | font-size: 16px; 181 | overflow: auto; 182 | } 183 | 184 | .properties-area::-webkit-scrollbar, .keyframes-area::-webkit-scrollbar { 185 | display: none; 186 | } 187 | .properties-area { 188 | width: 30%; 189 | max-width: 200px; 190 | box-sizing: border-box; 191 | } 192 | .values-area { 193 | width: 50px; 194 | min-width: 50px; 195 | display: inline-block; 196 | border-right: 1px solid #666; 197 | box-sizing: border-box; 198 | } 199 | .value input { 200 | appearance: none; 201 | -webkit-appearance: none; 202 | outline: none; 203 | position: relative; 204 | display: block; 205 | width: 100%; 206 | height: 100%; 207 | background: transparent; 208 | color: #4af; 209 | font-weight: bold; 210 | background: none; 211 | border: 0; 212 | box-sizing: border-box; 213 | text-align: center; 214 | } 215 | .value { 216 | 217 | } 218 | .alt .value input { 219 | cursor: ew-resize; 220 | } 221 | .value[data-object="1"] input { 222 | display: none; 223 | } 224 | .properties-scroll-area { 225 | display: inline-block; 226 | min-width: 100%; 227 | } 228 | .keyframes-area { 229 | flex: 1; 230 | } 231 | .keyframes-scroll-area { 232 | position: relative; 233 | min-width: 300px; 234 | } 235 | .keyframes, .property, .value { 236 | position: relative; 237 | height: 30px; 238 | line-height: 30px; 239 | border-bottom: 1px solid #555; 240 | box-sizing: border-box; 241 | white-space: nowrap; 242 | background: rgba(90, 90, 90, 0.7); 243 | z-index: 1; 244 | } 245 | 246 | .property { 247 | padding-left: 10px; 248 | box-sizing: border-box; 249 | font-size: 13px; 250 | font-weight: bold; 251 | color: #eee; 252 | } 253 | .property .remove { 254 | position: absolute; 255 | display: inline-block; 256 | cursor: pointer; 257 | width: 18px; 258 | height: 18px; 259 | top: 0; 260 | bottom: 0; 261 | right: 10px; 262 | margin: auto; 263 | border-radius: 50%; 264 | border: 2px solid #fff; 265 | vertical-align: middle; 266 | display: none; 267 | margin-left: 10px; 268 | box-sizing: border-box; 269 | } 270 | .property .remove:before, .property .remove:after { 271 | position: absolute; 272 | content: ""; 273 | width: 8px; 274 | height: 2px; 275 | border-radius: 1px; 276 | background: #fff; 277 | top: 0; 278 | left: 0; 279 | right: 0; 280 | bottom: 0; 281 | margin: auto; 282 | } 283 | .property .remove:before { 284 | transform: rotate(45deg); 285 | } 286 | .property .remove:after { 287 | transform: rotate(-45deg); 288 | } 289 | .property:hover .remove { 290 | display: inline-block; 291 | } 292 | 293 | [data-item="1"], [data-item="1"] .add { 294 | height: 30px; 295 | line-height: 30px; 296 | } 297 | .time-area { 298 | position: absolute; 299 | top: 0; 300 | left: 10px; 301 | font-size: 13px; 302 | color: #4af; 303 | line-height: 30px; 304 | font-weight: bold; 305 | height: 100%; 306 | line-height: 30px; 307 | border: 0; 308 | background: transparent; 309 | outline: 0; 310 | } 311 | .time-area:after { 312 | content: "s"; 313 | } 314 | .property .arrow { 315 | position: relative; 316 | display: inline-block; 317 | width: 20px; 318 | height: 25px; 319 | cursor: pointer; 320 | vertical-align: middle; 321 | } 322 | .property .arrow:after { 323 | content: ""; 324 | position: absolute; 325 | top: 0; 326 | right: 0; 327 | left: 0; 328 | bottom: 0; 329 | margin: auto; 330 | width: 0; 331 | height: 0; 332 | border-top: 6px solid #eee; 333 | border-left: 4px solid transparent; 334 | border-right: 4px solid transparent; 335 | } 336 | .property[data-fold="1"] .arrow:after { 337 | border-top: 4px solid transparent; 338 | border-bottom: 4px solid transparent; 339 | border-right: 0; 340 | border-left: 6px solid #eee; 341 | } 342 | .property[data-object="0"] .arrow { 343 | display: none; 344 | } 345 | .property.fold, .keyframes.fold, .value.fold { 346 | display: none; 347 | } 348 | .property.select, .value.select, .keyframes.select { 349 | background: rgba(120, 120, 120, 0.7); 350 | } 351 | .keyframes { 352 | 353 | } 354 | .keyframe-delay { 355 | position: absolute; 356 | top: 3px; 357 | bottom: 3px; 358 | left: 0; 359 | background: #4af; 360 | opacity: 0.2; 361 | z-index: 0; 362 | } 363 | .keyframe-group { 364 | position: absolute; 365 | top: 3px; 366 | bottom: 3px; 367 | left: 0; 368 | background: #4af; 369 | opacity: 0.6; 370 | border: 1px solid rgba(0, 0, 0, 0.2); 371 | border-left-color: rgba(255, 255, 255, 0.2); 372 | border-top-color: rgba(255, 255, 255, 0.2); 373 | z-index: 0; 374 | } 375 | .keyframe-line { 376 | position: absolute; 377 | height: 8px; 378 | top: 0; 379 | bottom: 0; 380 | margin: auto; 381 | background: #666; 382 | z-index: 0; 383 | } 384 | .keyframe { 385 | position: absolute; 386 | font-size: 0px; 387 | width: 12px; 388 | height: 12px; 389 | top: 0px; 390 | bottom: 0px; 391 | margin: auto; 392 | background: #fff; 393 | border: 2px solid #383838; 394 | border-radius: 2px; 395 | box-sizing: border-box; 396 | transform: translate(-50%) rotate(45deg); 397 | z-index: 1; 398 | cursor: pointer; 399 | } 400 | .keyframe[data-no="1"] { 401 | opacity: 0.2; 402 | } 403 | .select .keyframe { 404 | border-color: #555; 405 | } 406 | .keyframe.select { 407 | background: #4af; 408 | } 409 | .keyframes-container, .line-area { 410 | position: relative; 411 | width: calc(100% - 30px); 412 | left: 15px; 413 | height: 100%; 414 | } 415 | .line-area { 416 | position: absolute; 417 | top: 0; 418 | z-index: 0; 419 | } 420 | .keyframe-cursor { 421 | position: absolute; 422 | top: 0; 423 | z-index: 1; 424 | background: #4af; 425 | width: 1px; 426 | height: 100%; 427 | left: 15px; 428 | transform: translate(-50%); 429 | } 430 | .scroll-aare .keyframe-cursor { 431 | pointer-events: none; 432 | } 433 | .division-line { 434 | position: absolute; 435 | background: #333; 436 | width: 1px; 437 | height: 100%; 438 | transform: translate(-50%); 439 | }`; 440 | 441 | const Styler = styled("div", css); 442 | const Styler2 = styled("div", ".a {}"); 443 | 444 | const App: React.FC = () => { 445 | const ref1 = React.useRef(null); 446 | return ( 447 |
448 | 449 | 1111 450 | 451 | 452 | 2222 453 | 454 | 455 | 3333 456 | 457 | 458 | 4444 459 | 460 |
461 | ); 462 | } 463 | 464 | export default App; 465 | --------------------------------------------------------------------------------