.
This commit is contained in:
21
node_modules/@tailwindcss/typography/LICENSE
generated
vendored
Normal file
21
node_modules/@tailwindcss/typography/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Tailwind Labs, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
26
node_modules/@tailwindcss/typography/README.md
generated
vendored
Normal file
26
node_modules/@tailwindcss/typography/README.md
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<p>
|
||||
<a href="https://tailwindcss.com/docs/typography-plugin#gh-light-mode-only" target="_blank">
|
||||
<img src="./.github/logo-light.svg" alt="Tailwind CSS Typography" width="450" height="70">
|
||||
</a>
|
||||
<a href="https://tailwindcss.com/docs/typography-plugin#gh-dark-mode-only" target="_blank">
|
||||
<img src="./.github/logo-dark.svg" alt="Tailwind CSS Typography" width="450" height="70">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
A plugin that provides a set of `prose` classes you can use to add beautiful typographic defaults to any vanilla HTML you don't control, like HTML rendered from Markdown, or pulled from a CMS.
|
||||
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
For full documentation, visit [tailwindcss.com/docs/typography-plugin](https://tailwindcss.com/docs/typography-plugin).
|
||||
|
||||
## Community
|
||||
|
||||
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
||||
|
||||
[Discuss the Tailwind CSS Typography plugin on GitHub](https://github.com/tailwindlabs/tailwindcss/discussions)
|
||||
|
||||
For casual chit-chat with others using the framework:
|
||||
|
||||
[Join the Tailwind CSS Discord Server](https://tailwindcss.com/discord)
|
||||
59
node_modules/@tailwindcss/typography/package.json
generated
vendored
Normal file
59
node_modules/@tailwindcss/typography/package.json
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "@tailwindcss/typography",
|
||||
"version": "0.5.9",
|
||||
"description": "A Tailwind CSS plugin for automatically styling plain HTML content with beautiful typographic defaults.",
|
||||
"main": "src/index.js",
|
||||
"types": "src/index.d.ts",
|
||||
"files": [
|
||||
"src/*.js",
|
||||
"src/*.d.ts",
|
||||
"dist/"
|
||||
],
|
||||
"repository": "https://github.com/tailwindcss/typography",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 100,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"dev": "next dev demo",
|
||||
"build": "next build demo",
|
||||
"export": "next export demo",
|
||||
"start": "next start demo"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"tailwindcss": ">=3.0.0 || insiders"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mdx-js/loader": "^1.0.19",
|
||||
"@mdx-js/mdx": "^1.6.6",
|
||||
"@next/mdx": "^8.1.0",
|
||||
"autoprefixer": "^10.2.1",
|
||||
"highlight.js": "^10.4.1",
|
||||
"jest": "^26.6.1",
|
||||
"jest-diff": "^27.3.1",
|
||||
"next": "^12.0.1",
|
||||
"postcss": "^8.2.3",
|
||||
"prettier": "^2.1.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"tailwindcss": "^3.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash.castarray": "^4.4.0",
|
||||
"lodash.isplainobject": "^4.0.6",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"postcss-selector-parser": "6.0.10"
|
||||
},
|
||||
"jest": {
|
||||
"setupFilesAfterEnv": [
|
||||
"<rootDir>/jest/customMatchers.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
9
node_modules/@tailwindcss/typography/src/index.d.ts
generated
vendored
Normal file
9
node_modules/@tailwindcss/typography/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
declare function plugin(options?: Partial<{ className: string; target: 'modern' | 'legacy' }>): {
|
||||
handler: () => void
|
||||
}
|
||||
|
||||
declare namespace plugin {
|
||||
const __isOptionsFunction: true
|
||||
}
|
||||
|
||||
export = plugin
|
||||
139
node_modules/@tailwindcss/typography/src/index.js
generated
vendored
Normal file
139
node_modules/@tailwindcss/typography/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
const plugin = require('tailwindcss/plugin')
|
||||
const merge = require('lodash.merge')
|
||||
const castArray = require('lodash.castarray')
|
||||
const styles = require('./styles')
|
||||
const { commonTrailingPseudos } = require('./utils')
|
||||
|
||||
const computed = {
|
||||
// Reserved for future "magic properties", for example:
|
||||
// bulletColor: (color) => ({ 'ul > li::before': { backgroundColor: color } }),
|
||||
}
|
||||
|
||||
function inWhere(selector, { className, modifier, prefix }) {
|
||||
let prefixedNot = prefix(`.not-${className}`).slice(1)
|
||||
let selectorPrefix = selector.startsWith('>')
|
||||
? `${modifier === 'DEFAULT' ? `.${className}` : `.${className}-${modifier}`} `
|
||||
: ''
|
||||
|
||||
// Parse the selector, if every component ends in the same pseudo element(s) then move it to the end
|
||||
let [trailingPseudo, rebuiltSelector] = commonTrailingPseudos(selector)
|
||||
|
||||
if (trailingPseudo) {
|
||||
return `:where(${selectorPrefix}${rebuiltSelector}):not(:where([class~="${prefixedNot}"] *))${trailingPseudo}`
|
||||
}
|
||||
|
||||
return `:where(${selectorPrefix}${selector}):not(:where([class~="${prefixedNot}"] *))`
|
||||
}
|
||||
|
||||
function isObject(value) {
|
||||
return typeof value === 'object' && value !== null
|
||||
}
|
||||
|
||||
function configToCss(config = {}, { target, className, modifier, prefix }) {
|
||||
function updateSelector(k, v) {
|
||||
if (target === 'legacy') {
|
||||
return [k, v]
|
||||
}
|
||||
|
||||
if (Array.isArray(v)) {
|
||||
return [k, v]
|
||||
}
|
||||
|
||||
if (isObject(v)) {
|
||||
let nested = Object.values(v).some(isObject)
|
||||
if (nested) {
|
||||
return [
|
||||
inWhere(k, { className, modifier, prefix }),
|
||||
v,
|
||||
Object.fromEntries(Object.entries(v).map(([k, v]) => updateSelector(k, v))),
|
||||
]
|
||||
}
|
||||
|
||||
return [inWhere(k, { className, modifier, prefix }), v]
|
||||
}
|
||||
|
||||
return [k, v]
|
||||
}
|
||||
|
||||
return Object.fromEntries(
|
||||
Object.entries(
|
||||
merge(
|
||||
{},
|
||||
...Object.keys(config)
|
||||
.filter((key) => computed[key])
|
||||
.map((key) => computed[key](config[key])),
|
||||
...castArray(config.css || {})
|
||||
)
|
||||
).map(([k, v]) => updateSelector(k, v))
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = plugin.withOptions(
|
||||
({ className = 'prose', target = 'modern' } = {}) => {
|
||||
return function ({ addVariant, addComponents, theme, prefix }) {
|
||||
let modifiers = theme('typography')
|
||||
|
||||
let options = { className, prefix }
|
||||
|
||||
for (let [name, ...selectors] of [
|
||||
['headings', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'th'],
|
||||
['h1'],
|
||||
['h2'],
|
||||
['h3'],
|
||||
['h4'],
|
||||
['h5'],
|
||||
['h6'],
|
||||
['p'],
|
||||
['a'],
|
||||
['blockquote'],
|
||||
['figure'],
|
||||
['figcaption'],
|
||||
['strong'],
|
||||
['em'],
|
||||
['code'],
|
||||
['pre'],
|
||||
['ol'],
|
||||
['ul'],
|
||||
['li'],
|
||||
['table'],
|
||||
['thead'],
|
||||
['tr'],
|
||||
['th'],
|
||||
['td'],
|
||||
['img'],
|
||||
['video'],
|
||||
['hr'],
|
||||
['lead', '[class~="lead"]'],
|
||||
]) {
|
||||
selectors = selectors.length === 0 ? [name] : selectors
|
||||
|
||||
let selector =
|
||||
target === 'legacy' ? selectors.map((selector) => `& ${selector}`) : selectors.join(', ')
|
||||
|
||||
addVariant(
|
||||
`${className}-${name}`,
|
||||
target === 'legacy' ? selector : `& :is(${inWhere(selector, options)})`
|
||||
)
|
||||
}
|
||||
|
||||
addComponents(
|
||||
Object.keys(modifiers).map((modifier) => ({
|
||||
[modifier === 'DEFAULT' ? `.${className}` : `.${className}-${modifier}`]: configToCss(
|
||||
modifiers[modifier],
|
||||
{
|
||||
target,
|
||||
className,
|
||||
modifier,
|
||||
prefix,
|
||||
}
|
||||
),
|
||||
}))
|
||||
)
|
||||
}
|
||||
},
|
||||
() => {
|
||||
return {
|
||||
theme: { typography: styles },
|
||||
}
|
||||
}
|
||||
)
|
||||
1324
node_modules/@tailwindcss/typography/src/index.test.js
generated
vendored
Normal file
1324
node_modules/@tailwindcss/typography/src/index.test.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1452
node_modules/@tailwindcss/typography/src/styles.js
generated
vendored
Normal file
1452
node_modules/@tailwindcss/typography/src/styles.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
62
node_modules/@tailwindcss/typography/src/utils.js
generated
vendored
Normal file
62
node_modules/@tailwindcss/typography/src/utils.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
const isPlainObject = require('lodash.isplainobject')
|
||||
|
||||
const parser = require('postcss-selector-parser')
|
||||
const parseSelector = parser()
|
||||
|
||||
module.exports = {
|
||||
isUsableColor(color, values) {
|
||||
return isPlainObject(values) && color !== 'gray' && values[600]
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} selector
|
||||
*/
|
||||
commonTrailingPseudos(selector) {
|
||||
let ast = parseSelector.astSync(selector)
|
||||
|
||||
/** @type {import('postcss-selector-parser').Pseudo[][]} */
|
||||
let matrix = []
|
||||
|
||||
// Put the pseudo elements in reverse order in a sparse, column-major 2D array
|
||||
for (let [i, sel] of ast.nodes.entries()) {
|
||||
for (const [j, child] of [...sel.nodes].reverse().entries()) {
|
||||
// We only care about pseudo elements
|
||||
if (child.type !== 'pseudo' || !child.value.startsWith('::')) {
|
||||
break
|
||||
}
|
||||
|
||||
matrix[j] = matrix[j] || []
|
||||
matrix[j][i] = child
|
||||
}
|
||||
}
|
||||
|
||||
let trailingPseudos = parser.selector()
|
||||
|
||||
// At this point the pseudo elements are in a column-major 2D array
|
||||
// This means each row contains one "column" of pseudo elements from each selector
|
||||
// We can compare all the pseudo elements in a row to see if they are the same
|
||||
for (const pseudos of matrix) {
|
||||
// It's a sparse 2D array so there are going to be holes in the rows
|
||||
// We skip those
|
||||
if (!pseudos) {
|
||||
continue
|
||||
}
|
||||
|
||||
let values = new Set([...pseudos.map((p) => p.value)])
|
||||
|
||||
// The pseudo elements are not the same
|
||||
if (values.size > 1) {
|
||||
break
|
||||
}
|
||||
|
||||
pseudos.forEach((pseudo) => pseudo.remove())
|
||||
trailingPseudos.prepend(pseudos[0])
|
||||
}
|
||||
|
||||
if (trailingPseudos.nodes.length) {
|
||||
return [trailingPseudos.toString(), ast.toString()]
|
||||
}
|
||||
|
||||
return [null, selector]
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user