Skip to content

Commit 7af4903

Browse files
committed
Update docs for modules
1 parent 1de13d8 commit 7af4903

4 files changed

Lines changed: 207 additions & 9 deletions

File tree

docs/pages/modules/fields/index.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,28 @@ End-to-end tests with [Playwright](https://playwright.dev/).
217217
npm run e2e
218218
```
219219

220+
### Storybook
221+
222+
Frontend workshop for building UI components and pages in isolation with [Storybook](https://storybook.js.org)
223+
224+
Start Storybook in dev mode, to watch files and rebuild.
225+
226+
```
227+
npm run storybook
228+
```
229+
230+
It serves on a random port by default. To specify a port number:
231+
232+
```
233+
npm run storybook -- -p 6006
234+
```
235+
236+
Build Storybook for publishing.
237+
238+
```
239+
npm run storybook:build
240+
```
241+
220242
## Render fields
221243

222244
To render a field, we use `$fields->render_field`. It takes 2 arguments:

docs/pages/modules/roller/index.md

Lines changed: 157 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Create a file called `tangible.config.js` in your project folder.
125125
Example:
126126

127127
```js
128-
module.exports = {
128+
export default {
129129
build: [
130130
{
131131
src: 'src/index.js',
@@ -176,10 +176,162 @@ Its value is one of:
176176

177177
The following optional task properties perform various substitutions.
178178

179-
- `alias` - Map import module name to target module name or file path
180-
- `importToGlobal` - Map import module name to global variable name; supports dynamic name such as `@example/*`, for which a function should be given that takes the module name and returns the variable name
181-
- `globalToImport` - Map global variable name to import module name
182-
- `replaceStrings` - Map string to another string
179+
##### alias
180+
181+
Using `alias` you can map an import module name to target another module name or file path. This uses rollup's [alias](https://github.com/rollup/plugins/tree/master/packages/alias#custom-resolvers) plugin under the hood.
182+
183+
Here's an example use of the `alias` parameter:
184+
185+
```js
186+
export default {
187+
build: [
188+
{
189+
src: 'src/index.js',
190+
dest: 'build/app.min.js',
191+
alias: [
192+
{
193+
find: 'src',
194+
replacement: path.resolve(projectRootDir, 'src')
195+
}
196+
]
197+
},
198+
// ...
199+
}
200+
```
201+
202+
##### importToGlobal
203+
204+
Using `importToGlobal` you can map import module names to global variable names. It supports dynamic names such as `@example/*`, for which a function should be given that takes the module name and returns the variable name:
205+
206+
```js
207+
export default {
208+
build: [
209+
{
210+
src: 'src/index.js',
211+
dest: 'build/app.min.js',
212+
importToGlobal: {
213+
'@my-namespace/*': 'myGlobalVar.*'
214+
}
215+
},
216+
// ...
217+
}
218+
```
219+
220+
In WordPress mode Roller imports `@wordpress/*` into the global variable `wp.*`.
221+
222+
##### globalToImport
223+
224+
Using `globalToImport` would be a reverse situation of using `importToGlobal`. Here you can map a global variable name to an import module name. This uses Rollup's [inject](https://github.com/rollup/plugins/tree/master/packages/inject) plugin under the hood.
225+
226+
```js
227+
export default {
228+
build: [
229+
{
230+
src: 'src/index.js',
231+
dest: 'build/app.min.js',
232+
globalToImport: {
233+
// import { Promise } from 'es6-promise'
234+
Promise: [ 'es6-promise', 'Promise' ],
235+
236+
// import { Promise as P } from 'es6-promise'
237+
P: [ 'es6-promise', 'Promise' ],
238+
239+
// import $ from 'jquery'
240+
$: 'jquery',
241+
242+
// import * as fs from 'fs'
243+
fs: [ 'fs', '*' ],
244+
245+
// use a local module instead of a third-party one
246+
'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
247+
}
248+
},
249+
// ...
250+
}
251+
```
252+
253+
##### replaceStrings
254+
255+
Using `replaceStrings` you can [map a string to another string](https://github.com/rollup/plugins/tree/master/packages/replace) during script processing. It can be handy for replacing placeholders with actual values at build time.
256+
257+
```js
258+
export default {
259+
build: [
260+
{
261+
src: 'src/index.js',
262+
dest: 'build/app.min.js',
263+
replaceStrings: {
264+
'process.env.NODE_ENV': 'production',
265+
__buildDate__: () => new Date(),
266+
__buildVersion__: 15
267+
},
268+
replaceInclude: [
269+
path.resolve( 'some/path/' ),
270+
/\.[jt]sx?$/,
271+
/node_modules/
272+
]
273+
},
274+
// ...
275+
}
276+
```
277+
278+
The given values are encoded with `JSON.stringify()`.
279+
280+
By default, the string replacement applies to all files. Optionally use `replaceInclude` to specify an array of include file patterns.
281+
282+
The above replacements will convert this:
283+
284+
```js
285+
const buildTimeValues = {
286+
date: __buildDate__,
287+
version: __buildVersion__
288+
}
289+
```
290+
291+
..into..
292+
293+
```js
294+
const buildTimeValues = {
295+
date: "2025-09-16T15:26:54.280Z",
296+
version: 15
297+
}
298+
```
299+
300+
##### replaceCode
301+
302+
This is similar to `replaceStrings`, but it replaces the source with literal code instead of JSON string. It's useful for replacing a placeholder with code that evaluates to a value at run time.
303+
304+
To demonstrate the difference:
305+
306+
```js
307+
{
308+
replaceCode: {
309+
'process.env.NODE_ENV': '"production"'
310+
__currentDate__: 'new Date()'
311+
__currentVersion__: '15'
312+
}
313+
}
314+
```
315+
316+
The date constant will be replaced by the given code to get a new `Date` instance, instead of a string value evaluated at build time. The version constant will be replaced by the code `15`.
317+
318+
The above replacements will convert this:
319+
320+
```js
321+
const runTimeValues = {
322+
date: __currentDate__,
323+
version: __currentVersion__
324+
}
325+
```
326+
327+
..into..
328+
329+
```js
330+
const runTimeValues = {
331+
date: new Date(),
332+
version: 15
333+
}
334+
```
183335

184336
#### HTML
185337

docs/pages/modules/template-system/modules/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Do not edit this file - Generated from https://github.com/tangibleinc/template-s
2525
- [Pager](pager)
2626
- [Prism](prism)
2727
- [Sass](sass)
28+
- [Select](select)
29+
- [Site structure](site-structure)
2830
- [Slider](slider)
2931
- [Sortable](sortable)
3032
- [Table](table)

docs/pages/modules/updater/index.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,28 @@ add_action('plugins_loaded', function() {
7070

7171
Register the plugin with its name and file path.
7272

73+
### Framework
74+
75+
When registering with the Framework module, the same plugin instance can be passed to the Updater.
76+
77+
```php
78+
use tangible\framework;
79+
use tangible\updater;
80+
81+
require_once __DIR__ . '/vendor/tangible/framework/index.php';
82+
require_once __DIR__ . '/vendor/tangible/updater/index.php';
83+
84+
add_action('plugins_loaded', function() {
85+
86+
$plugin = framework\register_plugin([
87+
'name' => 'example-plugin',
88+
// ...
89+
]);
90+
91+
updater\register_plugin($plugin);
92+
});
93+
```
94+
7395
### Cloud
7496

7597
Optionally set the property `cloud_id` to pass additional parameters to the update server.
@@ -78,13 +100,13 @@ Optionally set the property `cloud_id` to pass additional parameters to the upda
78100
updater\register_plugin([
79101
'name' => $plugin->name,
80102
'file' => __FILE__,
81-
'cloud_id' => '', // Plugin ID (Required)
82-
'api' => '', // Update API server's URL (Optional)
83-
]
103+
'cloud_id' => '', // Plugin ID (Required)
104+
'updater_url' => '', // Update server URL (Optional)
105+
'activation_url' => '', // License activation URL (Optional)
84106
]);
85107
```
86108

87-
#### License settings page
109+
### Licensing
88110

89111
This feature requires a plugin to be registered with the [Framework](https://github.com/tangibleinc/framework) module, which adds a plugin settings page.
90112

0 commit comments

Comments
 (0)