• Stars
    star
    1,003
  • Rank 44,163 (Top 0.9 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎩 Lettering.js in vanilla JavaScript

charming npm Version Build Status Coverage Status Bundle Size

Lettering.js in vanilla JavaScript

  • Supports changing the tag name or class name of the inserted DOM elements
  • Supports controlling how the contents of the element are wrapped

Usage

Editable demo (CodePen)

HTML:

<h1>foo</h1>

JavaScript:

const charming = require('charming')

const element = document.querySelector('h1')
charming(element)

Boom:

<h1 aria-label="foo">
  <span class="char1" aria-hidden="true">f</span>
  <span class="char2" aria-hidden="true">o</span>
  <span class="char3" aria-hidden="true">o</span>
</h1>
  • Charming also works when the given element contains other (possibly nested) DOM elements; any character that is inside a text node in the given element will be wrapped.
  • For accessibility, Charming adds an aria-label attribute on the given element and aria-hidden attributes on each of the inserted DOM elements.

API

const charming = require('charming')

charming(element [, options])

  • element is a DOM element
  • options is an optional configuration object

Use options.tagName to change the tag name of the wrapper element:

charming(element, {
  tagName: 'b'
})

Use options.setClassName to change the class name on each wrapper element:

charming(element, {
  setClassName: function (index, letter) {
    return `index-${index} letter-${letter}`
  }
})

Use options.split to control how the contents of the element are wrapped:

charming(element, {
  split: function (string) {
    return string.split(/(\s+)/)
  },
  setClassName: function (index) {
    return `word-${index}`
  }
})

Installation

$ yarn add charming

License

MIT

More Repositories

1

vdx

🎞️ An intuitive CLI for processing video, powered by FFmpeg
TypeScript
1,659
star
2

create-figma-plugin

🔋 The comprehensive toolkit for developing plugins and widgets for Figma and FigJam
TypeScript
867
star
3

malarkey

⌨️ Simulate a typewriter effect in vanilla JavaScript.
JavaScript
238
star
4

figma-plugins

🔥 Monorepo for my Figma plugins
TypeScript
228
star
5

ffmpeg-cheatsheet

📼 A cheatsheet for common video processing operations in FFmpeg
175
star
6

load-google-maps-api

🌏 A lightweight Promise-returning helper for loading the Google Maps JavaScript API
JavaScript
170
star
7

vim-basics

✌️ Just the basics to get you up and running with Vim
Vim Script
133
star
8

stable-diffusion-rest-api

🤗 Run Stable Diffusion locally via a REST API on an M1/M2 MacBook
TypeScript
124
star
9

line-clamp

🗜️ Line clamp a DOM element in vanilla JavaScript
JavaScript
75
star
10

autosize-input

🎈 Effortless, dynamic-width text boxes in vanilla JavaScript
JavaScript
67
star
11

figma-plugins-stats

📈 A CLI to get live and historical stats for your Figma plugins
TypeScript
60
star
12

cuba

🇨🇺 Google Sheets + SQL = JSON
JavaScript
53
star
13

single-page-markdown-website

🌶️ Create a nice single-page documentation website from one or more Markdown files
TypeScript
44
star
14

menu-aim

🎯 Instant mega menus in vanilla JavaScript.
JavaScript
39
star
15

fastmatter

👀 A fast frontmatter parser. Supports both string and stream inputs.
JavaScript
28
star
16

awesome-create-figma-plugin

27
star
17

generate-css

💥 Dynamically generate functional CSS classes from HTML and JavaScript source files
TypeScript
16
star
18

stoke

🌲 Generate the Abstract Syntax Tree (AST) of a Bash command
JavaScript
15
star
19

regular-expressions-cheatsheet

🅰️ A concise cheatsheet for using Regular Expressions in JavaScript
JavaScript
15
star
20

gulp-tape

👻 Run Tape tests in Gulp.
JavaScript
14
star
21

generate-ts-docs

📘 Utilities to parse type information and JSDoc annotations from TypeScript source files, and render Markdown documentation
TypeScript
12
star
22

macos-keyboard-shortcuts

⌨️ A CLI to set application-specific keyboard shortcuts for macOS
TypeScript
12
star
23

shell-basics

🐚 A quick overview of the Unix shell
11
star
24

rdd

📝 Preview your Markdown locally as it would appear on GitHub, with live updating
JavaScript
11
star
25

code-problems

🐫 Working through code problems in OCaml
OCaml
7
star
26

git-cheatsheet

🌳 A handy list of commonly used Git commands
6
star
27

interpolate

Simple string interpolation in PHP.
PHP
5
star
28

sketch-plugin-helper

Utilities to help you make Sketch plugins
JavaScript
5
star
29

sketch-plugins

Monorepo for my Sketch plugins
JavaScript
5
star
30

quine

✍️ Programs that write themselves.
Shell
5
star
31

grouper

Assign objects to groups by one or more properties, by object value, or by using a comparator function.
JavaScript
4
star
32

modal

Super-simple modals in vanilla JavaScript.
JavaScript
4
star
33

react-redux-modal

🔮 A React modal bound to the Redux store.
JavaScript
4
star
34

yuanqing.sg

⚪ My personal website
HTML
3
star
35

widget

TypeScript
3
star
36

sketch-handbook

📙 A concise handbook on working precisely and effectively in Sketch
Shell
3
star
37

figma-plugins-monetization-stats

JavaScript
3
star
38

figma-add-auto-layout-item

TypeScript
2
star
39

versus

Compare two variables with the comparison operator specified as a string.
JavaScript
2
star
40

google-sheets-rest-api

JavaScript
2
star
41

q

🍦 An opinionated CLI for creating lightweight, vanilla HTML/CSS websites
JavaScript
2
star
42

jockey

Modelling a playlist that supports shuffle, repeat, and reordering.
JavaScript
2
star
43

xoxo

🎧 A YouTube mixtape maker thing.
JavaScript
2
star
44

extract

Sugar for getting data out of strings in PHP.
PHP
2
star
45

asset-versioning

🗃️ Version your assets by appending a hash to the filename.
JavaScript
2
star
46

fi

Query a collection of text files like a document database in PHP.
PHP
2
star
47

Q.js

A micro JavaScript library.
JavaScript
2
star
48

shared-event-listeners

A utility for minimising the number of event listeners bound on a given DOM element.
JavaScript
2
star
49

create-figma-plugin-react-example

JavaScript
2
star
50

sketch-add-artboard-borders-and-titles

JavaScript
2
star
51

figmake

🍦 A tiny CLI for making Figma plugins in HTML, CSS, and vanilla JavaScript
TypeScript
2
star
52

savoy

Higher-order functions (synchronous and asynchronous each/eachSeries/map/filter/fold) and functions for flow control (parallel/series/waterfall) in under 1 KB.
JavaScript
1
star
53

string-extractor

Regular expression sugar for getting data out of strings.
JavaScript
1
star
54

cli

TypeScript
1
star
55

cors

JavaScript
1
star
56

kontact

An extensible contact form in PHP and vanilla JavaScript/AJAX.
JavaScript
1
star
57

abstract-backup

💾 Download a local backup of the Sketch files from all your Abstract projects
JavaScript
1
star
58

sketch-sort-layer-list

JavaScript
1
star
59

clinical

💊 A minimum-viable arguments parser in ~90 LOC with zero dependencies
TypeScript
1
star
60

sketch-select-layers

JavaScript
1
star
61

npm-boilerplate

Barebones boilerplate using `npm run-script`.
JavaScript
1
star
62

google-sheets

🍃 An easier interface to read from and write to Google Sheets
JavaScript
1
star
63

sketch-clean-document

JavaScript
1
star
64

gulp-boilerplate

A Gulp-powered boilerplate for Node and JavaScript projects.
JavaScript
1
star
65

segue

Enqueue functions, and call them in series.
JavaScript
1
star
66

unfurl

Extract the query string and hash of a URL.
JavaScript
1
star
67

sketch-extract-text

JavaScript
1
star
68

bbqr

JavaScript
1
star
69

sketch-move-layers

JavaScript
1
star
70

pppath

Join strings to form a valid file path.
JavaScript
1
star
71

screen-recorder

JavaScript
1
star
72

simple-code-editor

TypeScript
1
star
73

resizable

TypeScript
1
star
74

svg-inserter

TypeScript
1
star
75

build-website

TypeScript
1
star
76

.github

1
star
77

eslint-config-yuanqing

⚙️ An opinionated ESLint configuration for TypeScript and Preact projects
JavaScript
1
star
78

append-js-extension-to-local-imports

JavaScript
1
star
79

stylelint-config-yuanqing

🕴️ An opinionated stylelint configuration
JavaScript
1
star
80

sketch-draw-slice-over-selection

JavaScript
1
star
81

sketch-align-to-grid

JavaScript
1
star
82

frontend-boilerplate

🌱 Super basic web boilerplate with Sass and vanilla JavaScript.
HTML
1
star
83

isomorphic

JavaScript
1
star
84

tsu

Utilities and functional wrappers over `through2`.
JavaScript
1
star
85

sketch-rename-layers

🖋️ [WIP] A Sketch plugin to automate layer renaming
JavaScript
1
star
86

johnson-trotter

An implementation of the Johnson-Trotter permutation algorithm.
JavaScript
1
star
87

rectify

Unsmarten your quotes, dashes, and ellipses.
JavaScript
1
star
88

react-autocomplete

[UNMAINTAINED] React autocomplete component with an opinionated UX.
JavaScript
1
star