Skip to content

Instantly share code, notes, and snippets.

@dylanlindgren
Last active August 20, 2020 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dylanlindgren/a03d1659595307052a3705ff59cdb5f4 to your computer and use it in GitHub Desktop.
Save dylanlindgren/a03d1659595307052a3705ff59cdb5f4 to your computer and use it in GitHub Desktop.
Component Modal Test
{
"development": {
"proxy": {
"proxies": ["/api"]
}
},
"styles": {
"themes": [{
"module": "@servicenow/sass-theme",
"main": ["theme.scss"],
"copyFiles": ["type/*", "*.scss"]
}]
}
}
{
"components": {
"x-180672-snc-component-modal-test": {
"innerComponents": []
}
},
"scopeName": "x_180672_snc_com_0"
}
{
"name": "snc-component-modal-test",
"version": "0.0.1",
"private": false,
"description": "",
"keywords": [
"ServiceNow",
"Now Experience UI Component",
"snc-component-modal-test"
],
"readme": "./README.md",
"engines": {
"node": ">=8.6.0",
"npm": ">=5.3.0"
},
"module": "src/index.js",
"dependencies": {
"@servicenow/cli-archetype": "17.0.3",
"@servicenow/cli-component-archetype": "17.0.3",
"@servicenow/library-translate": "orlando",
"@servicenow/now-dropdown": "^17.0.1",
"@servicenow/sass-kit": "orlando",
"@servicenow/sass-theme": "orlando",
"@servicenow/ui-core": "orlando",
"@servicenow/ui-renderer-snabbdom": "orlando"
},
"devDependencies": {
"@servicenow/cli-archetype-dev": "17.0.3",
"@servicenow/cli-component-archetype-dev": "17.0.3"
}
}
import { createCustomElement } from '@servicenow/ui-core';
import snabbdom from '@servicenow/ui-renderer-snabbdom';
import '@servicenow/now-dropdown';
import styles from './styles.scss';
const handleSelect = ({action, dispatch}) => {
dispatch('SN_SCRIPTED_MODAL#DATA_SET', {
selectedValue: properties.selectedValue
});
}
const view = ({properties}, dispatch) => {
dispatch('SN_SCRIPTED_MODAL#DATA_SET', {
selectedValue: properties.selectedValue
});
return (
<div>
<now-dropdown
items={properties.options}
size="md"
select="single"
selected-items={[properties.selectedValue]}
/>
</div>
);
};
createCustomElement('x-180672-snc-component-modal-test', {
renderer: { type: snabbdom },
view,
styles,
actionHandlers: {
'NOW_DROPDOWN#SELECTED_ITEMS_SET': handleSelect
},
properties: {
options: {
default: [{
label: 'First Option',
id: 'one'
}, {
label: 'Option 2',
id: 'two'
}]
},
selectedValue: {
default: 'one'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment