diff --git a/docs/quickstart.md b/docs/quickstart.md index 628fe81..edce1d8 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -8,9 +8,9 @@ ## Install -### Automatic +### Automatic -``` bash +```bash # install the cli app npm install -g create-proton-app # create your project @@ -24,4 +24,4 @@ You can alternatively use `npx` if you prefer. ### Manual -The old manual instructions are still available [here](manual_install.md) \ No newline at end of file +The old manual instructions are still available [here](manual_install.md) diff --git a/src/components/DesktopComponent.js b/src/components/DesktopComponent.js index 61221cd..9751adb 100644 --- a/src/components/DesktopComponent.js +++ b/src/components/DesktopComponent.js @@ -8,8 +8,17 @@ import { MenuBar, } from './'; import { Menu } from '../'; +import { + ITEM, + CHECK, + QUIT, + PREFERENCES, + ABOUT, + SEPARATOR +} from '../constants/types'; import PropTypes from 'prop-types'; + const functionMappings = { onChange: 'onChanged', onClose: 'onClosing', @@ -103,17 +112,17 @@ class DesktopComponent { // we assume we are a ComboBox.Item, and just append the child parent.element.append(this.props.children); } else if (parent instanceof MenuBar) { - if (this.props.type === 'Item') { + if (this.props.type === ITEM) { this.element = parent.element.appendItem(this.props.children); - } else if (this.props.type === 'Check') { + } else if (this.props.type === CHECK) { this.element = parent.element.appendCheckItem(this.props.children); - } else if (this.props.type === 'Quit') { + } else if (this.props.type === QUIT) { this.element = parent.element.appendQuitItem(); - } else if (this.props.type === 'Preferences') { + } else if (this.props.type === PREFERENCES) { this.element = parent.element.appendPreferencesItem(); - } else if (this.props.type === 'About') { + } else if (this.props.type === ABOUT) { this.element = parent.element.appendAboutItem(); - } else if (this.props.type === 'Separator') { + } else if (this.props.type === SEPARATOR) { parent.element.appendSeparator(); } } else if (this instanceof Menu) { diff --git a/src/components/MenuBar.js b/src/components/MenuBar.js index e0a1498..721ce93 100644 --- a/src/components/MenuBar.js +++ b/src/components/MenuBar.js @@ -2,6 +2,14 @@ import DesktopComponent, { universalPropTypes, universalDefaultProps, } from './DesktopComponent'; +import { + ITEM, + CHECK, + QUIT, + PREFERENCES, + ABOUT, + SEPARATOR +} from '../constants/types'; import libui from 'libui-node'; import PropTypes from 'prop-types'; @@ -57,12 +65,12 @@ MenuBar.Item.PropTypes = { children: PropTypes.string, checked: PropTypes.bool, type: PropTypes.oneOf([ - 'Check', - 'Quit', - 'About', - 'Preferences', - 'Separator', - 'Item', + CHECK, + QUIT, + ABOUT, + PREFERENCES, + SEPARATOR, + ITEM, ]), onClick: PropTypes.func, ...universalPropTypes, @@ -71,7 +79,7 @@ MenuBar.Item.PropTypes = { MenuBar.Item.defaultProps = { children: '', checked: false, - type: 'Item', + type: ITEM, onClick: () => {}, ...universalDefaultProps, }; diff --git a/src/constants/types.js b/src/constants/types.js new file mode 100644 index 0000000..0e13960 --- /dev/null +++ b/src/constants/types.js @@ -0,0 +1,6 @@ +export const ITEM = 'Item'; +export const CHECK = 'Check'; +export const QUIT = 'Quit'; +export const PREFERENCES = 'Preferences'; +export const ABOUT = 'About'; +export const SEPARATOR = 'Separator';