Dropdown
If there are too many operations to display, you can wrap them in a Dropdown by usingDropdown. By clicking/hovering on the trigger, a dropdown menu should appear, which allows you to choose one option and execute relevant actions.
Basic Dropdown
Dropdown menu can be passed to menu of dropdown to give options inside a basic dropdown.
On Hover
Dropdown menu can be passed to targetHover to change the trigger from click to hover
Note that no focus effects and iconChange work on hover trigger
Small Size
Default w of dropdown is 100%, the w can be changed to either fit-content or some other value in px or rem.
Loading Dropdown
isLoading can be passed to dropdown to replace the right icon with loading. Alternatively, a Loading icon can be passed to the the prefix, activeSuffix or inactiveSuffix of the dropdown.
Custom Styling
Any of the utilies can be applied to the dropdown. In addition openSuffix, closeSuffix, focusBorderColor & focusBg can also be applied for Custom Styling.
Dropdown Positions
direction for the menu can be specified which can have value topleft, topleft, topright, righttop, bottomright & bottomleft.
// Basic Dropdownimport { Dropdown, Anchor } from "atomize";const menuList = (<Div>{["Option 1", "Option 2", "Option 3"].map((name, index) => (<Anchor d="block" p={{ y: "0.25rem" }}>{name}</Anchor>))}</Div>);class BasicDropdown extends React.Component {constructor(props) {super(props);this.state = {showDropdown: false,};}render() {const { showDropdown } = this.state;return (<DropdownisOpen={showDropdown}onClick={() =>this.setState({ showDropdown: !showDropdown })}menu={menuList}>Click me</Dropdown>);}}export default BasicDropdown;
Modal
When requiring users to interact with the application, but without jumping to a new page and interrupting the user's workflow, you can use Modal to create a new floating layer over the current page. You need to pass isOpen & onClose to the Modal.
Alignments
Modal can be aligned centered by passing align="center". Additionally m can be controlled as shown in utilities.
Size
Submit Modal
// Basic Modalimport { Div, Button, Modal, Icon, Text } from "atomize";const AlignStartModal = ({ isOpen, onClose }) => {return (<Modal isOpen={isOpen} onClose={onClose} align="start" rounded="md"><Iconname="Cross"pos="absolute"top="1rem"right="1rem"size="16px"onClick={onClose}cursor="pointer"/><Div d="flex" m={{ b: "4rem" }}><Iconname="AlertSolid"color="warning700"m={{ t: "0.35rem", r: "0.5rem" }}/><Text p={{ l: "0.5rem", t: "0.25rem" }} textSize="subheader">Do you really want to submit the request.</Text></Div><Div d="flex" justify="flex-end"><ButtononClick={onClose}bg="gray200"textColor="medium"m={{ r: "1rem" }}>Cancel</Button><Button onClick={onClose} bg="info700">Yes, Submit</Button></Div></Modal>);};class BasicModal extends React.Component {constructor(props) {super(props);this.state = {showModal: false};}render() {const { showModal } = this.state;return (<><Buttonbg="info700"hoverBg="info600"m={{ b: "1rem" }}onClick={() => this.setState({ showModal: true })}>Open Basic Modal (Align Start)</Button><AlignStartModalisOpen={showModal}onClose={() => this.setState({ showModal: false })}/></>);}}export default BasicModal;
Sidedrawer
If there are too many operations to display, you can wrap them in a Dropdown. By clicking/hovering on the trigger, a dropdown menu should appear, which allows you to choose one option and execute relevant actions.
Basic Sidedrawer
A basic SideDrawer need to be passed isOpen & onClose to work.
Size
SideDrawer size can be modified by passing the w props for the desired width.
Note that you need to pass an array for responsive sidebar w.
// Basic Sidedrawerimport { Div, Button, SideDrawer, Icon, Text } from "atomize";const BasicSideDrawer = ({ isOpen, onClose }) => {return (<SideDrawer isOpen={isOpen} onClose={onClose}><Div d="flex" m={{ b: "4rem" }}><Icon name="AlertSolid" color="warning700" /><Text p={{ l: "0.5rem", t: "0.25rem" }}>This is the modal</Text></Div><Div d="flex" justify="flex-end"><ButtononClick={onClose}bg="gray200"textColor="medium"m={{ r: "1rem" }}>Cancel</Button><Button onClick={onClose} bg="info700">Submit</Button></Div></SideDrawer>);};class Drawer extends React.Component {constructor(props) {super(props);this.state = {showSideDrawer: false};}render() {const { showSideDrawer } = this.state;return (<><Buttonbg="info700"hoverBg="info600"m={{ r: "0.5rem" }}onClick={() => this.setState({ showSideDrawer: true })}>Show Basic Sidedrawer</Button><BasicSideDrawerisOpen={showSideDrawer}onClose={() => this.setState({ showSideDrawer: false })}/></>);}}export default Drawer;
Notification
Notification can be used to give feedbacks or short messages to the user. isOpen & onClose needs to be passed for the notification to work. In addition, prefix & suffix can be used to put icons with the notifications.
Type
Notification are of two types - auto closed & closed by users. If onClose is passed to the notification it becomes auto closed notifation.
Dark Notifications
Light Notifications
// Auto Closed Notifiationimport { Div, Button, Notification } from "atomize";class MyNotifation extends React.Component {constructor(props) {super(props);this.state = {showNotification: false};}render() {const { showNotification } = this.state;return (<><Buttonbg="gray700"hoverBg="gray600"m={{ r: "0.5rem" }}onClick={() => this.setState({ showNotification: true })}>Show auto close notification</Button><NotificationisOpen={showNotification}onClose={() => this.setState({ showNotification: false })}>This notification is self closable</Notification></>);}}export default MyNotifation;