Skip to content

Commit

Permalink
chore: use htm instead of JSX
Browse files Browse the repository at this point in the history
This makes it easier to adopt the examples in existing Projects

closes #206
  • Loading branch information
marstamm committed May 8, 2023
1 parent 3b8f775 commit 81a7d3b
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 87 deletions.
8 changes: 0 additions & 8 deletions properties-panel-async-extension/.babelrc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { html } from 'htm/preact';

import { SelectEntry, isSelectEntryEdited } from '@bpmn-io/properties-panel';
import { useService } from 'bpmn-js-properties-panel'

Expand Down Expand Up @@ -57,14 +59,14 @@ function Spell(props) {
];
}

return <SelectEntry
id={ id }
element={ element }
description={ translate('Apply a black magic spell') }
label={ translate('Spell') }
getValue={ getValue }
setValue={ setValue }
getOptions={ getOptions }
debounce={ debounce }
/>
return html`<${SelectEntry}
id=${ id }
element=${ element }
description=${ translate('Apply a black magic spell') }
label=${ translate('Spell') }
getValue=${ getValue }
setValue=${ setValue }
getOptions=${ getOptions }
debounce=${ debounce }
/>`
}
4 changes: 1 addition & 3 deletions properties-panel-async-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
],
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.16.5",
"@babel/plugin-transform-react-jsx": "^7.16.5",
"babel-loader": "^8.2.3",
"copy-webpack-plugin": "^10.1.0",
"css-loader": "^6.5.1",
"less": "^4.1.2",
Expand All @@ -51,6 +48,7 @@
"bpmn-js-properties-panel": "^1.9.0",
"cors": "^2.8.5",
"express": "^4.17.2",
"htm": "^3.1.1",
"jquery": "^3.5.1",
"min-dash": "^4.0.0"
}
Expand Down
18 changes: 0 additions & 18 deletions properties-panel-async-extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@ module.exports = {
devtool: 'source-map',
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
plugins: [
[ '@babel/plugin-transform-react-jsx', {
'importSource': '@bpmn-io/properties-panel/preact',
'runtime': 'automatic'
} ]
]
}
}
},
{
test: /\.less$/i,
use: [
Expand All @@ -54,9 +39,6 @@ module.exports = {
'module',
'main'
],
alias: {
'react': '@bpmn-io/properties-panel/preact/compat'
},
modules: [
'node_modules',
absoluteBasePath
Expand Down
8 changes: 0 additions & 8 deletions properties-panel-extension/.babelrc

This file was deleted.

22 changes: 12 additions & 10 deletions properties-panel-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ function createMagicGroup(element, translate) {

### Define an Entry

The "spell" entry is defined in [`SpellProps`](app/provider/magic/parts/SpellProps.js). We reuse [`TextFieldEntry`](https://github.com/bpmn-io/properties-panel/blob/main/src/components/entries/TextField.js) to create a text field for the property.
The "spell" entry is defined in [`SpellProps`](app/provider/magic/parts/SpellProps.js). We reuse [`TextFieldEntry`](https://github.com/bpmn-io/properties-panel/blob/main/src/components/entries/TextField.js) to create a text field for the property. The `component` needs to be a Preact component. We use [`htm`](https://github.com/developit/htm) to create a Preact component from a tagged template.

```javascript
import { html } from 'htm/preact';

import { TextFieldEntry, isTextFieldEntryEdited } from '@bpmn-io/properties-panel';
import { useService } from 'bpmn-js-properties-panel'

Expand Down Expand Up @@ -130,15 +132,15 @@ function Spell(props) {
});
}

return <TextFieldEntry
id={ id }
element={ element }
description={ translate('Apply a black magic spell') }
label={ translate('Spell') }
getValue={ getValue }
setValue={ setValue }
debounce={ debounce }
/>;
return html`<${TextFieldEntry}
id=${ id }
element=${ element }
description=${ translate('Apply a black magic spell') }
label=${ translate('Spell') }
getValue=${ getValue }
setValue=${ setValue }
debounce=${ debounce }
/>`
}
```

Expand Down
20 changes: 11 additions & 9 deletions properties-panel-extension/app/provider/magic/parts/SpellProps.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { html } from 'htm/preact';

import { TextFieldEntry, isTextFieldEntryEdited } from '@bpmn-io/properties-panel';
import { useService } from 'bpmn-js-properties-panel';

Expand Down Expand Up @@ -30,13 +32,13 @@ function Spell(props) {
});
}

return <TextFieldEntry
id={ id }
element={ element }
description={ translate('Apply a black magic spell') }
label={ translate('Spell') }
getValue={ getValue }
setValue={ setValue }
debounce={ debounce }
/>
return html`<${TextFieldEntry}
id=${ id }
element=${ element }
description=${ translate('Apply a black magic spell') }
label=${ translate('Spell') }
getValue=${ getValue }
setValue=${ setValue }
debounce=${ debounce }
/>`
}
4 changes: 1 addition & 3 deletions properties-panel-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
],
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.16.5",
"@babel/plugin-transform-react-jsx": "^7.16.5",
"babel-loader": "^8.2.3",
"copy-webpack-plugin": "^10.1.0",
"css-loader": "^6.5.1",
"less": "^4.1.2",
Expand All @@ -49,6 +46,7 @@
"@bpmn-io/properties-panel": "^1.0.0",
"bpmn-js": "^13.0.3",
"bpmn-js-properties-panel": "^1.9.0",
"htm": "^3.1.1",
"jquery": "^3.5.1",
"min-dash": "^4.0.0"
}
Expand Down
18 changes: 0 additions & 18 deletions properties-panel-extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@ module.exports = {
devtool: 'source-map',
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
plugins: [
[ '@babel/plugin-transform-react-jsx', {
'importSource': '@bpmn-io/properties-panel/preact',
'runtime': 'automatic'
} ]
]
}
}
},
{
test: /\.less$/i,
use: [
Expand All @@ -54,9 +39,6 @@ module.exports = {
'module',
'main'
],
alias: {
'react': '@bpmn-io/properties-panel/preact/compat'
},
modules: [
'node_modules',
absoluteBasePath
Expand Down

0 comments on commit 81a7d3b

Please sign in to comment.