Markdown Converter
Agent skill for markdown-converter
generic skill
Sign in to like and favorite skills
import { confirm, notify, alert, Button, Icon, Title, Text, Provider, AlertPanel, Card, } from "@concrete-design/core"; import styled from "styled-components";
Sometimes we need to get user confirmation after a form submission or any other interaction. Borwsers have built-in functions like
confirm that can get user validation but it won't be style.
With React it can be a pain to add a validation modal after submition. We came up with functions helpers inspired by
sweeetAlert that help us adding confirmation modals or even more complexe form called
asynchronously.
Concrete exports a
confirm function that return a promise waiting for user response.
import { confirm, notify, Button } from "@concrete-design/core"; const MyComponent = () => { const handleSubmit = async () => { const hasConfirmed = confirm("Do you want to confirm ?"); notify(`User response ${hasConfirmed ? "yes" : "no"}`); }; return <Button onClick={handleSubmit}>Click Me!</Button>; };
export const BasicConfirmUsage = () => { const handleSubmit = async () => { const hasConfirmed = await confirm({ message: "Do you want to confirm ?", confirmLabel: "Yes", cancelLabel: "No", }); notify(
User response is ${hasConfirmed ? "yes" : "no"});
};
return ;
};
notify allows to render a sweet message at the bottom of the page from anywhere in the code
as long as the code is behind the Provider.
const MyComponent = () => ( <Button onClick={() => notify("I can be called from anwhere !")}> Click Me! </Button> );
<Button onClick={() => notify("I can be called from anwhere !")}> Click Me!
const MyComponent = () => ( <Button onClick={() => notify({ message: "hi", illustration: <Icon icon="3D-building-outline" />, }) } > Click Me! </Button> );
<Button
onClick={() =>
notify({ message: "hi", illustration:
Click Me!
const MyComponent = () => { const message = ( <div> <Title type="regular">Title</Title> <Text>Text</Text> </div> ); return <Button onClick={() => notify({ message })}>Click Me!</Button>; };
<Button onClick={() => notify({ message: (
Click Me!
You can pass directly markdown to
notify if you need more complex rendering without passing jsx
const MyComponent = () => ( <Button onClick={() => notify({ message: "**hi in bold**", markdown: true })}> Click Me! </Button> );
<Button onClick={() => notify({ message: "hi in bold", markdown: true })}> Click Me!
You can pass a 2nd argument to notify to configure the notification as you like
duration: numbertype: 'info | 'warning' | 'error'const MyComponent = () => ( <Button onClick={() => notify("ERROR !", { duration: 10_000, type: "error" })} > Click Me! </Button> );
export const TypeContainer = styled.div
display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 24px;;
alert allows to add an AlertBanner at the very top of your application, where you placed your Provider.
const MyComponent = () => { return <Button onClick={() => alert("I'm an alert !"}>Click Me!</Button>; };
Prompt is a full customizable async util that render either a
Modal or a LightBox
prompt takes a function as first argument that should return an object with a Component field.
It returns a promise that is resolved by calling the onResolve function passed in the object of the first argument.
A
Modal is used by default but you can pass fullscreen: true to use the LightBox component.
Other Modal or LightBox props can be passed as params.
import { prompt } from "@concrete-design/core"; const formResult = await prompt(({ onResolve }) => ({ Component: () => <form onSubmit={onResolve}>// you form</form>, })); if (formResult) { // use your form result }