Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@kano/kbc-dialog
Advanced tools
kbc-dialog
A basic modal dialog plus Context Provider, or HOC injectable into Kano boilerplate apps.
import { DialogProvider, DialogConfig, DialogContext, KbcDialog } from '@kano/kbc-dialog';
const Component = (props) => {
return (
<DialogProvider>
...
<DialogContext.Consumer>
{(config: DialogConfig) => (
<KbcDialog config={config} title="Your message" />
)}
</DialogContext.Consumer>
...
<DialogContext.Consumer>
{(config: DialogConfig) => (
<button onClick={config.showDialog}>Open Dialog</button>
)}
</DialogContext.Consumer>
...
</DialogProvider>
)
}
If using the optional backdrop, nest the KbcDialog directly within the component div you want to be covered by the backdrop.
You can wrap the main part of the app, since you will probably want to overlay everything (including Nav), in a HOC called withDialog
, this will provide the hiding and showing functionality, and can be passed down as props if needed elsewhere. You can also pass up KbcDialog components to set the current dialog you want to show before triggering the dialog. If you have multiple dialogs, you can also set an array of dialogs here and trigger a specific one.
import { withDialog, IDialogAPI } from '@kano/kbc-dialog';
class OutsideOfNavAndBulkOfApp {
renderDialogs = () => {
if (this.state.currentDialog) {
return this.state.currentDialog();
}
return '';
}
render() {
return (
<Main>
...
<this.renderDialogs />
</Main>
);
}
}
export default withDialog(OutsideOfNavAndBulkOfApp);
And with the DialogProvider
being wrapper around the whole App
, e.g.:
import { DialogProvider } from '@kano/kbc-dialog';
const render = (messages?: any, optRoot?: HTMLElement) => {
ReactDOM.render(
<DialogProvider>
<AppProvider config={config} />
</DialogProvider>
optRoot || MOUNT_NODE,
);
};
There are also a selection of custom dialogs:
Component (location) | Function | Event / Error Name | Extra Info |
---|---|---|---|
KbcDialog | confirmHandler | confirm_dialog | module: kbc-dialog , action: click |
KbcDialog | cancelHandler | cancel_dialog | module: kbc-dialog , action: click |
ClearDialog | dismiss | dismiss_dialog | module: clear-dialog , action: click |
ClearDialog | fireCallback | confirm_callback | module: clear-dialog , action: click |
WarningDialog | okay | warning_acknowledged | module: warning-dialog , action: click |
RewardsDialog | next | next_challange_requested | module: rewards-dialog , action: click |
RewardsDialog | close | close_dialog | module: rewards-dialog , action: click |
NextChallengeDialog | fireCallback | confirm_callback | module: next-challenge-dialog , action: click |
FAQs
Injectable dialog into mini apps
The npm package @kano/kbc-dialog receives a total of 24 weekly downloads. As such, @kano/kbc-dialog popularity was classified as not popular.
We found that @kano/kbc-dialog demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.