diff --git a/docs/src/components/ComponentDoc/ComponentExample/ComponentExample.js b/docs/src/components/ComponentDoc/ComponentExample/ComponentExample.js
index 3bdc769bc4..7589bfa03a 100644
--- a/docs/src/components/ComponentDoc/ComponentExample/ComponentExample.js
+++ b/docs/src/components/ComponentDoc/ComponentExample/ComponentExample.js
@@ -1,9 +1,10 @@
+import { KnobProvider } from '@stardust-ui/docs-components'
import cx from 'classnames'
import copyToClipboard from 'copy-to-clipboard'
import PropTypes from 'prop-types'
import React, { Component } from 'react'
import VisibilitySensor from 'react-visibility-sensor'
-import { Grid } from 'semantic-ui-react'
+import { Checkbox, Grid, Label } from 'semantic-ui-react'
import { examplePathToHash, scrollToAnchor } from 'docs/src/utils'
import CarbonAdNative from 'docs/src/components/CarbonAd/CarbonAdNative'
@@ -11,6 +12,7 @@ import formatCode from 'docs/src/utils/formatCode'
import ComponentControls from '../ComponentControls'
import ExampleEditor from '../ExampleEditor'
import ComponentDocContext from '../ComponentDocContext'
+import ComponentExampleKnobs from './ComponentExampleKnobs'
import ComponentExampleTitle from './ComponentExampleTitle'
const childrenStyle = {
@@ -23,6 +25,29 @@ const componentControlsStyle = {
width: 'auto',
}
+/* eslint-disable react/prop-types */
+const knobComponents = {
+ KnobControl: (props) => (
+
+ {props.children}
+
+ ),
+ KnobBoolean: (props) => (
+ props.setValue(data.checked)}
+ type='checkbox'
+ value={props.value}
+ />
+ ),
+ KnobLabel: (props) => (
+
+ ),
+}
+/* eslint-enable react/prop-types */
+
/**
* Renders a `component` and the raw `code` that produced it.
* Allows toggling the the raw `code` code block.
@@ -78,9 +103,7 @@ class ComponentExample extends Component {
if (wasCodeChanged) {
/* eslint-disable-next-line no-console */
console.warn(
- `[HMR] the code of example (${
- props.examplePath
- }) was not reload because it was modified, please reset your changes.`,
+ `[HMR] the code of example (${props.examplePath}) was not reload because it was modified, please reset your changes.`,
)
} else {
derivedState.originalSourceCode = props.sourceCode
@@ -173,27 +196,31 @@ class ComponentExample extends Component {
/>
+
+
- {children && (
-
- {children}
+ {children && (
+
+ {children}
+
+ )}
+
+
+
- )}
-
-
-
-
+
+
{isActiveHash && }
diff --git a/docs/src/components/ComponentDoc/ComponentExample/ComponentExampleKnobs.js b/docs/src/components/ComponentDoc/ComponentExample/ComponentExampleKnobs.js
new file mode 100644
index 0000000000..6e1470f595
--- /dev/null
+++ b/docs/src/components/ComponentDoc/ComponentExample/ComponentExampleKnobs.js
@@ -0,0 +1,43 @@
+import { CodeSnippet, KnobInspector, useKnobValues } from '@stardust-ui/docs-components'
+import _ from 'lodash'
+import React from 'react'
+import { Grid } from 'semantic-ui-react'
+
+const columnStyles = {
+ padding: 0,
+}
+
+const knobsStyles = {
+ background: 'whitesmoke',
+ color: '#777',
+ lineHeight: '1.5',
+ padding: '1rem',
+}
+
+const rowStyles = {
+ padding: 0,
+}
+
+const ComponentExampleKnobs = () => {
+ const knobValues = useKnobValues()
+ const values = _.fromPairs(knobValues.map((knob) => [knob.name, knob.value]))
+
+ return (
+
+ {(knobs) =>
+ knobs && (
+
+
+ {knobs}
+
+
+
+
+
+ )
+ }
+
+ )
+}
+
+export default ComponentExampleKnobs
diff --git a/docs/src/components/ComponentDoc/ExampleEditor/renderConfig.js b/docs/src/components/ComponentDoc/ExampleEditor/renderConfig.js
index 33cf224934..edb9f03276 100644
--- a/docs/src/components/ComponentDoc/ExampleEditor/renderConfig.js
+++ b/docs/src/components/ComponentDoc/ExampleEditor/renderConfig.js
@@ -1,3 +1,4 @@
+import * as docsComponents from '@stardust-ui/docs-components'
import faker from 'faker'
import React from 'react'
import PropTypes from 'prop-types'
@@ -16,6 +17,7 @@ export const babelConfig = {
}
export const externals = {
+ '@stardust-ui/docs-components': docsComponents,
faker,
lodash: require('lodash'),
react: React,
diff --git a/docs/src/components/ExternalExampleLayout.js b/docs/src/components/ExternalExampleLayout.js
index 71862a3ef4..5fbc95d646 100644
--- a/docs/src/components/ExternalExampleLayout.js
+++ b/docs/src/components/ExternalExampleLayout.js
@@ -1,11 +1,12 @@
+import { KnobProvider } from '@stardust-ui/docs-components'
import PropTypes from 'prop-types'
-import { createElement } from 'react'
+import React, { createElement } from 'react'
import { withRouteData } from 'react-static'
const ExternalExampleLayout = (props) => {
const exampleComponent = require(`docs/src/examples/${props.path}`).default
- return createElement(exampleComponent)
+ return {createElement(exampleComponent)}
}
ExternalExampleLayout.propTypes = {
diff --git a/docs/src/examples/modules/Popup/Usage/PopupExampleActions.js b/docs/src/examples/modules/Popup/Usage/PopupExampleActions.js
index 3c47111415..28e19b1d95 100644
--- a/docs/src/examples/modules/Popup/Usage/PopupExampleActions.js
+++ b/docs/src/examples/modules/Popup/Usage/PopupExampleActions.js
@@ -26,7 +26,7 @@ const PopupExampleActions = () => (
Click me or Hover me}
+ trigger={}
header='Movie Search'
content='Multiple events can trigger a popup'
on={['hover', 'click']}
diff --git a/docs/src/examples/modules/Popup/Usage/PopupExampleEventsEnabled.js b/docs/src/examples/modules/Popup/Usage/PopupExampleEventsEnabled.js
new file mode 100644
index 0000000000..57e7f9c94f
--- /dev/null
+++ b/docs/src/examples/modules/Popup/Usage/PopupExampleEventsEnabled.js
@@ -0,0 +1,25 @@
+import { useBooleanKnob } from '@stardust-ui/docs-components'
+import React from 'react'
+import { Button, Popup } from 'semantic-ui-react'
+
+const PopupExampleEventsEnabled = () => {
+ const [eventsEnabled] = useBooleanKnob({
+ name: 'eventsEnabled',
+ initialValue: true,
+ })
+ const [open, setOpen] = useBooleanKnob({ name: 'open' })
+
+ return (
+ setOpen(false)}
+ onOpen={() => setOpen(true)}
+ open={open}
+ trigger={}
+ />
+ )
+}
+
+export default PopupExampleEventsEnabled
diff --git a/docs/src/examples/modules/Popup/Usage/index.js b/docs/src/examples/modules/Popup/Usage/index.js
index ecd10d3b36..ae5737c8e4 100644
--- a/docs/src/examples/modules/Popup/Usage/index.js
+++ b/docs/src/examples/modules/Popup/Usage/index.js
@@ -44,6 +44,34 @@ const PopupUsageExamples = () => (
target='_blank'
/>
+ eventsEnabled}
+ description={
+
+ Enables the Popper.js
event listeners.
+
+ }
+ examplePath='modules/Popup/Usage/PopupExampleEventsEnabled'
+ />
+
+ A popup can have dependencies which update will schedule a position
+ update. Should be used in cases when content is changing, behaves like{' '}
+
+ dependencies
+ {' '}
+ in React Hooks.
+
+ }
+ examplePath='modules/Popup/Usage/PopupExamplePopperDependencies'
+ renderHtml={false}
+ />
(
examplePath='modules/Popup/Usage/PopupExampleDefaultOpen'
renderHtml={false}
/>
-
- A popup can have dependencies which update will schedule a position
- update. Should be used in cases when content is changing, behaves like{' '}
-
- dependencies
- {' '}
- in React Hooks.
-
- }
- examplePath='modules/Popup/Usage/PopupExamplePopperDependencies'
- renderHtml={false}
- />
)
diff --git a/src/modules/Popup/Popup.d.ts b/src/modules/Popup/Popup.d.ts
index 6b319bdd59..bb1ecbb97e 100644
--- a/src/modules/Popup/Popup.d.ts
+++ b/src/modules/Popup/Popup.d.ts
@@ -31,6 +31,9 @@ export interface StrictPopupProps extends StrictPortalProps {
/** A disabled popup only renders its trigger. */
disabled?: boolean
+ /** Enables the Popper.js event listeners. */
+ eventsEnabled?: boolean
+
/** A flowing Popup has no maximum width and continues to flow to fit its content. */
flowing?: boolean
diff --git a/src/modules/Popup/Popup.js b/src/modules/Popup/Popup.js
index 73cd0dbccc..d5cfd58070 100644
--- a/src/modules/Popup/Popup.js
+++ b/src/modules/Popup/Popup.js
@@ -52,6 +52,9 @@ export default class Popup extends Component {
/** A disabled popup only renders its trigger. */
disabled: PropTypes.bool,
+ /** Enables the Popper.js event listeners. */
+ eventsEnabled: PropTypes.bool,
+
/** A flowing Popup has no maximum width and continues to flow to fit its content. */
flowing: PropTypes.bool,
@@ -145,6 +148,7 @@ export default class Popup extends Component {
static defaultProps = {
disabled: false,
+ eventsEnabled: true,
offset: 0,
on: 'hover',
pinned: false,
@@ -319,7 +323,16 @@ export default class Popup extends Component {
}
render() {
- const { context, disabled, offset, pinned, popperModifiers, position, trigger } = this.props
+ const {
+ context,
+ disabled,
+ eventsEnabled,
+ offset,
+ pinned,
+ popperModifiers,
+ position,
+ trigger,
+ } = this.props
const { closed, portalRestProps } = this.state
if (closed || disabled) return trigger
@@ -351,6 +364,7 @@ export default class Popup extends Component {
triggerRef={this.triggerRef}
>
{
})
})
+ describe('eventsEnabled ', () => {
+ it(`is "true" by default`, () => {
+ wrapperMount()
+
+ wrapper.should.have.prop('eventsEnabled', true)
+ wrapper.find('Popper').should.have.prop('eventsEnabled', true)
+ })
+
+ it(`can be set to "false"`, () => {
+ wrapperMount()
+ wrapper.find('Popper').should.have.prop('eventsEnabled', false)
+ })
+ })
+
describe('flowing', () => {
it('adds flowing to the popup className', () => {
wrapperMount()