Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinmcfarland committed Aug 7, 2024
1 parent 2c77d86 commit 9502db7
Showing 1 changed file with 56 additions and 45 deletions.
101 changes: 56 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ Build output files using
mole.build()
```

## Configuration
## Config

By default, `mole` will look for a file called `mole.config.js` at the root of your project that exports the following object.

You can override the location of the config file by using `mole.config()`.

```js
mole.config('src/mole.config.js')
```ts
type Config {
theme: string,
model?: string[],
template?: string[],
output: Output
}
```

### Options
Expand Down Expand Up @@ -69,7 +72,17 @@ mole.config('src/mole.config.js')

An object that defines where (`file`) and how (`model`, `template`) to process the output. You can set a different `template` or `model` for each output. Name each output by using a key.

## API
```ts
type Output {
name: {
file: string
model?: string[],
template?: string[]
}
}
```

## Docs

- ### Set configuration

Expand All @@ -79,6 +92,12 @@ mole.config('src/mole.config.js')

- `config` { string | object } path to file, or object for config

#### Example

```js
mole.config('src/mole.config.js')
```

---

- ### Set or update theme data
Expand Down Expand Up @@ -107,63 +126,55 @@ mole.config('src/mole.config.js')

- ### Use a model or template that's been registered

`mole.use( part ): void`
`mole.use(type, name, callback): void`

#### Parameters

- `part` { array } :
- `type` { string } must be `'template'` or `'model'`
- `name` { string } name of the template or model
- `callback` { function | string } the body of the model or template
- `type` { string } must be `'template'` or `'model'`
- `name` { string } name of the template or model
- `callback` { function | string } the body of the model or template

---
#### Example

- ### Render an array of templates
Using a function:

`mole.render(): string[]`
```js
mole.use('template', 'font-size', (model, theme, name, str) => {
let scale = model[name]
---
for (let i = 0; i < scale.length; i++) {
str`
.$font-${i} {
font-size: ${scale[i]}
}`
}
- ### Build the output files

`mole.build()`
return str()
})
```

### Types
Using a string:

- **`Config`**
```js
mole.use('template', 'font-size',
```ts
type Config {
theme: string,
model?: string[],
template?: string[],
output: Output
}
`.font-{{modifier}} {
font-size: {{value}};
}`
})
```

- **`Output`**
---

```ts
type Output {
name: {
file: string
model?: string[],
template?: string[]
}
}
```
- ### Render an array of templates

- **`ModelCallback`**
`mole.render(): string[]`

```ts
type ModelCallback = (theme: object, name: string, str: string) => object
```
---

**`TemplateCallback`**
- ### Build the output files

```ts
type TemplateCallback = (model: object, theme: object, name: string, str: string) => object
```
`mole.build()`

## Development

Expand Down

0 comments on commit 9502db7

Please sign in to comment.