3.1.7 • Published 4 years ago

stylemark v3.1.7

Weekly downloads
1,711
License
MIT
Repository
github
Last release
4 years ago

Stylemark   npm version Build Status

Generate interactive style guides from Markdown.

Table of contents

Installation

Stylemark requires Node.js v8+

npm install stylemark

Usage

On the command line

npx stylemark <config> [-w|--watch]
ParameterDescription
<config>JS or JSON file containing a configuration object
-w, --watchOpens the generated styleguide in a browser and reloads when any matching input files are added or changed

In Node.js

const stylemark = require("stylemark")

stylemark(config)

Configuration

PropertyTypeDefaultDescription
inputstring or array of stringsInput path globs. See Globbing patterns.
outputstringOutput directory path. Directories will be automatically created if they don't exist.
cwdstringConfig file directoryBase path that input and output paths are relative to. By default, paths are resolved relative to the config file when using the command line.
namestringStylemarkDisplay name of the generated styleguide.

Example:

{
    input: ["src/**/*.{js,md}", "!*.test.js"],
    output: "dist/styleguide",
    name: "ACME Styleguide",
}

Globbing patterns

  • * matches any number of characters, but not /
  • ? matches a single character, but not /
  • ** matches any number of characters, including /, as long as it's the only thing in a path part
  • {} allows for a comma-separated list of "or" expressions
  • ! at the beginning of a pattern will negate the match

Documenting components

Components are documented using markdown in code comments or in separate markdown files.

In a source code comment

button.js:

/*
---
name: Button
---

Button variants:

```variants.jsx
<Button variant="primary">Primary</Button>
<Button variant="danger">Danger</Button>
```

Button sizes:

```sizes.jsx
<Button size="s">Small</Button>
<Button size="m">Medium</Button>
<Button size="l">Large</Button>
```
*/
export default ({ variant, size, children }) => {
    return <button className={`button -${variant} -${size}`}>{children}</button>
}

In a markdown file

button.md:

---
name: Button
---

Button variants:

```variants.jsx
<Button variant="primary">Primary</Button>
<Button variant="danger">Danger</Button>
```

Button sizes:

```sizes.jsx
<Button size="s">Small</Button>
<Button size="m">Medium</Button>
<Button size="l">Large</Button>
```

Specimens

A specimen is an interactive example made up of one or more named Markdown code blocks.

```form.html
<form>
    <input name="email" type="email" placeholder="name@example.com">
    <input name="password" type="password">
    <button type="submit">Log in</button>
</form>
```

```form.css
input, button { display: block }
```

```form.js
document.querySelector('form').addEventListener('submit', event => {
    event.preventDefault()
    alert('You logged in')
})
```

Specimen code blocks are insulated from each other. For instance, CSS styles defined for one specimen will not affect other specimens.

4.0.0-alpha.3

4 years ago

3.1.7

4 years ago

3.1.6

4 years ago

4.0.0-alpha.2

4 years ago

4.0.0-alpha.1

4 years ago

3.1.5

4 years ago

3.1.4

4 years ago

4.0.0-alpha.0

4 years ago

3.1.3

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.4

5 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.6.8

6 years ago

0.6.7

6 years ago

0.6.6

6 years ago

0.6.5

6 years ago

0.6.4

6 years ago

0.6.3

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.9

6 years ago

0.5.8

7 years ago

0.5.7

7 years ago

0.5.6

7 years ago

0.5.5

7 years ago

0.5.4

7 years ago

0.5.3

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago