├── .editorconfig ├── .gitattributes ├── .gitignore ├── .npmrc ├── .travis.yml ├── .yo-rc.json ├── cli.js ├── index.js ├── license ├── package.json ├── readme.md └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '12' 4 | - '10' 5 | - '8' 6 | -------------------------------------------------------------------------------- /.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-nm": { 3 | "promptValues": { 4 | "githubUsername": "manishrc", 5 | "website": "https://manishrc.com" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict'; 3 | const meow = require('meow'); 4 | const tailwindcssTypographyJs = require('.'); 5 | 6 | const cli = meow(` 7 | Usage 8 | $ tailwindcss-typography-js [input] 9 | 10 | Options 11 | --foo Lorem ipsum [Default: false] 12 | 13 | Examples 14 | $ tailwindcss-typography-js 15 | unicorns & rainbows 16 | $ tailwindcss-typography-js ponies 17 | ponies & rainbows 18 | `); 19 | 20 | console.log(tailwindcssTypographyJs(cli.input[0] || 'unicorns')); 21 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const Typography = require("typography"); 2 | const plugin = require("tailwindcss/plugin"); 3 | 4 | const DEFAULT_CONFIG = { 5 | includeNormalize: false, 6 | }; 7 | 8 | module.exports = function (config) { 9 | const theme = new Typography(Object.assign(DEFAULT_CONFIG, config)); 10 | 11 | return plugin(function ({ addBase }) { 12 | addBase(theme.toJSON()); 13 | }); 14 | }; 15 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Manish Chiniwalar (manishrc.com) 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@manishrc/tailwindcss-typography-js", 3 | "version": "0.1.7", 4 | "description": "Tailwind CSS plugin to inject Typography.js styles", 5 | "main": "index.js", 6 | "keywords": [ 7 | "tailwind", 8 | "tailwindcss", 9 | "typography", 10 | "plugin", 11 | "font", 12 | "css" 13 | ], 14 | "license": "MIT", 15 | "repository": "manishrc/tailwindcss-typography-js", 16 | "author": { 17 | "name": "Manish Chiniwalar", 18 | "email": "hi@manishrc.com", 19 | "url": "https://manishrc.com" 20 | }, 21 | "engines": { 22 | "node": ">=8" 23 | }, 24 | "scripts": {}, 25 | "files": [ 26 | "index.js" 27 | ], 28 | "dependencies": { 29 | "tailwindcss": "^1.2.0", 30 | "typography": "^0.16.19" 31 | }, 32 | "devDependencies": {} 33 | } 34 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # tailwindcss-typography-js [![Build Status](https://travis-ci.com/manishrc/tailwindcss-typography-js.svg?branch=master)](https://travis-ci.com/manishrc/tailwindcss-typography-js) 2 | 3 | > Tailwind CSS plugin to inject Typography.js styles 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm install --save @manishrc/tailwindcss-typography-js 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```js 14 | // tailwindcss.config.js 15 | const typography = require("@manishrc/tailwindcss-typography-js"); 16 | 17 | // Option 1 - Using a configuration 18 | const typographyTheme = typography({ 19 | baseFontSize: "18px", 20 | baseLineHeight: 1.666, 21 | headerFontFamily: ["Helvetica Neue", "sans-serif"], 22 | bodyFontFamily: ["Georgia", "serif"], 23 | }); 24 | 25 | // Option 2 - Using a theme 26 | import funstonTheme from "typography-theme-funston"; 27 | const typographyTheme = typography(funstonTheme); 28 | 29 | // Add to the plugin list. 30 | module.exports = { 31 | theme: { 32 | extend: {}, 33 | }, 34 | variants: {}, 35 | plugins: [typographyTheme], 36 | corePlugins: {}, 37 | }; 38 | ``` 39 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import tailwindcssTypographyJs from '.'; 3 | 4 | test('title', t => { 5 | t.throws(() => { 6 | tailwindcssTypographyJs(123); 7 | }, { 8 | instanceOf: TypeError, 9 | message: 'Expected a string, got number' 10 | }); 11 | 12 | t.is(tailwindcssTypographyJs('unicorns'), 'unicorns & rainbows'); 13 | }); 14 | --------------------------------------------------------------------------------