From f5d53a8a775b7b8635071084b36da8335c9574c5 Mon Sep 17 00:00:00 2001 From: mrholek Date: Fri, 26 Jul 2024 11:02:45 +0200 Subject: [PATCH 001/116] docs: update README --- README.md | 1 + packages/coreui-react/README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 7ba55b56..4b1884c3 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ import "bootstrap/dist/css/bootstrap.min.css"; - [React Progress](https://coreui.io/react/docs/components/progress/) - [React Radio](https://coreui.io/react/docs/forms/radio/) - [React Range](https://coreui.io/react/docs/forms/range/) +- [React Rating](https://coreui.io/react/docs/forms/rating/) - [React Select](https://coreui.io/react/docs/forms/select/) - [React Sidebar](https://coreui.io/react/docs/components/sidebar/) - [React Smart Pagination](https://coreui.io/react/docs/components/smart-pagination/) **PRO** diff --git a/packages/coreui-react/README.md b/packages/coreui-react/README.md index 13a31f8e..60d8b83c 100644 --- a/packages/coreui-react/README.md +++ b/packages/coreui-react/README.md @@ -134,6 +134,7 @@ import "bootstrap/dist/css/bootstrap.min.css"; - [React Progress](https://coreui.io/react/docs/components/progress/) - [React Radio](https://coreui.io/react/docs/forms/radio/) - [React Range](https://coreui.io/react/docs/forms/range/) +- [React Rating](https://coreui.io/react/docs/forms/rating/) - [React Select](https://coreui.io/react/docs/forms/select/) - [React Sidebar](https://coreui.io/react/docs/components/sidebar/) - [React Smart Pagination](https://coreui.io/react/docs/components/smart-pagination/) **PRO** From 8730020fa8482ef5bbcfd52f98e366809205714d Mon Sep 17 00:00:00 2001 From: mrholek Date: Fri, 2 Aug 2024 12:49:24 +0200 Subject: [PATCH 002/116] feat(CModal): add the `container` property to allow appending the modal to a specific element --- .../coreui-react/src/components/modal/CModal.tsx | 14 +++++++++++--- packages/docs/content/api/CModal.api.mdx | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/coreui-react/src/components/modal/CModal.tsx b/packages/coreui-react/src/components/modal/CModal.tsx index 053e8162..e02c3425 100644 --- a/packages/coreui-react/src/components/modal/CModal.tsx +++ b/packages/coreui-react/src/components/modal/CModal.tsx @@ -31,6 +31,12 @@ export interface CModalProps extends HTMLAttributes { * A string of all className you want applied to the base component. */ className?: string + /** + * Appends the react modal to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. + * + * @since 5.3.0 + */ + container?: DocumentFragment | Element | (() => DocumentFragment | Element | null) | null /** * @ignore */ @@ -38,7 +44,7 @@ export interface CModalProps extends HTMLAttributes { /** * Puts the focus on the modal when shown. * - * @since v4.10.0 + * @since 4.10.0 */ focus?: boolean /** @@ -101,6 +107,7 @@ export const CModal = forwardRef( alignment, backdrop = true, className, + container, duration = 150, focus = true, fullscreen, @@ -223,7 +230,7 @@ export const CModal = forwardRef( timeout={transition ? duration : 0} > {(state) => ( - +
( )} {backdrop && ( - + )} @@ -273,6 +280,7 @@ CModal.propTypes = { backdrop: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf<'static'>(['static'])]), children: PropTypes.node, className: PropTypes.string, + container: PropTypes.any, // HTMLElement duration: PropTypes.number, focus: PropTypes.bool, fullscreen: PropTypes.oneOfType([ diff --git a/packages/docs/content/api/CModal.api.mdx b/packages/docs/content/api/CModal.api.mdx index 635c688e..1f5a391a 100644 --- a/packages/docs/content/api/CModal.api.mdx +++ b/packages/docs/content/api/CModal.api.mdx @@ -10,7 +10,8 @@ import CModal from '@coreui/react/src/components/modal/CModal' | **alignment** | Align the modal in the center or top of the screen. | `'top'` \| `'center'` | - | | **backdrop** | Apply a backdrop on body while modal is open. | `boolean` \| `'static'` | true | | **className** | A string of all className you want applied to the base component. | `string` | - | -| **focus** **_v4.10.0+_** | Puts the focus on the modal when shown. | `boolean` | true | +| **container** **_5.3.0+_** | Appends the react modal to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `DocumentFragment` \| `(() => Element` \| `DocumentFragment)` | - | +| **focus** **_4.10.0+_** | Puts the focus on the modal when shown. | `boolean` | true | | **fullscreen** | Set modal to covers the entire user viewport. | `boolean` \| `'sm'` \| `'md'` \| `'lg'` \| `'xl'` \| `'xxl'` | - | | **keyboard** | Closes the modal when escape key is pressed. | `boolean` | true | | **onClose** | Callback fired when the component requests to be closed. | `() => void` | - | From 8c66f37a3b7675a5957183627a7e16921661047b Mon Sep 17 00:00:00 2001 From: mrholek Date: Fri, 2 Aug 2024 12:56:15 +0200 Subject: [PATCH 003/116] refactor(CDropdown, CPopover, CTooltip): update the `container` property typings --- .../conditional-portal/CConditionalPortal.tsx | 10 ++++++---- .../coreui-react/src/components/dropdown/CDropdown.tsx | 2 +- .../coreui-react/src/components/popover/CPopover.tsx | 2 +- .../coreui-react/src/components/tooltip/CTooltip.tsx | 2 +- packages/docs/content/api/CConditionalPortal.api.mdx | 4 ++-- packages/docs/content/api/CDropdown.api.mdx | 2 +- packages/docs/content/api/CPopover.api.mdx | 2 +- packages/docs/content/api/CTooltip.api.mdx | 2 +- 8 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/coreui-react/src/components/conditional-portal/CConditionalPortal.tsx b/packages/coreui-react/src/components/conditional-portal/CConditionalPortal.tsx index c1106bdc..5e228b19 100644 --- a/packages/coreui-react/src/components/conditional-portal/CConditionalPortal.tsx +++ b/packages/coreui-react/src/components/conditional-portal/CConditionalPortal.tsx @@ -2,7 +2,9 @@ import React, { FC, ReactNode, useEffect, useState } from 'react' import { createPortal } from 'react-dom' import PropTypes from 'prop-types' -const getContainer = (container?: Element | (() => Element | null) | null) => { +const getContainer = ( + container?: DocumentFragment | Element | (() => DocumentFragment | Element | null) | null, +) => { if (container) { return typeof container === 'function' ? container() : container } @@ -20,11 +22,11 @@ export interface CConditionalPortalProps { * * @since v4.11.0 */ - container?: Element | (() => Element | null) | null + container?: DocumentFragment | Element | (() => DocumentFragment | Element | null) | null /** * Render some children into a different part of the DOM */ - portal: boolean | any + portal: boolean } export const CConditionalPortal: FC = ({ @@ -48,7 +50,7 @@ export const CConditionalPortal: FC = ({ CConditionalPortal.propTypes = { children: PropTypes.node, container: PropTypes.any, // HTMLElement - portal: PropTypes.bool, + portal: PropTypes.bool.isRequired, } CConditionalPortal.displayName = 'CConditionalPortal' diff --git a/packages/coreui-react/src/components/dropdown/CDropdown.tsx b/packages/coreui-react/src/components/dropdown/CDropdown.tsx index 65101efc..992691a3 100644 --- a/packages/coreui-react/src/components/dropdown/CDropdown.tsx +++ b/packages/coreui-react/src/components/dropdown/CDropdown.tsx @@ -48,7 +48,7 @@ export interface CDropdownProps extends HTMLAttributes Element | null) | null + container?: DocumentFragment | Element | (() => DocumentFragment | Element | null) | null /** * Sets a darker color scheme to match a dark navbar. */ diff --git a/packages/coreui-react/src/components/popover/CPopover.tsx b/packages/coreui-react/src/components/popover/CPopover.tsx index 24a41c20..2abd14c8 100644 --- a/packages/coreui-react/src/components/popover/CPopover.tsx +++ b/packages/coreui-react/src/components/popover/CPopover.tsx @@ -24,7 +24,7 @@ export interface CPopoverProps extends Omit, 'tit * * @since v4.11.0 */ - container?: Element | (() => Element | null) | null + container?: DocumentFragment | Element | (() => DocumentFragment | Element | null) | null /** * Content node for your component. */ diff --git a/packages/coreui-react/src/components/tooltip/CTooltip.tsx b/packages/coreui-react/src/components/tooltip/CTooltip.tsx index 56158a3f..61891f64 100644 --- a/packages/coreui-react/src/components/tooltip/CTooltip.tsx +++ b/packages/coreui-react/src/components/tooltip/CTooltip.tsx @@ -24,7 +24,7 @@ export interface CTooltipProps extends Omit, 'con * * @since v4.11.0 */ - container?: Element | (() => Element | null) | null + container?: DocumentFragment | Element | (() => DocumentFragment | Element | null) | null /** * Content node for your component. */ diff --git a/packages/docs/content/api/CConditionalPortal.api.mdx b/packages/docs/content/api/CConditionalPortal.api.mdx index 4a269bf2..3817d616 100644 --- a/packages/docs/content/api/CConditionalPortal.api.mdx +++ b/packages/docs/content/api/CConditionalPortal.api.mdx @@ -7,5 +7,5 @@ import CConditionalPortal from '@coreui/react/src/components/conditional-portal/ | Property | Description | Type | Default | | --- | --- | --- | --- | -| **container** **_v4.11.0+_** | An HTML element or function that returns a single element, with `document.body` as the default. | `Element` \| `(() => Element)` | - | -| **portal** | Render some children into a different part of the DOM | `any` | - | +| **container** **_v4.11.0+_** | An HTML element or function that returns a single element, with `document.body` as the default. | `DocumentFragment` \| `Element` \| `(() => DocumentFragment` \| `Element)` | - | +| **portal** | Render some children into a different part of the DOM | `boolean` | - | diff --git a/packages/docs/content/api/CDropdown.api.mdx b/packages/docs/content/api/CDropdown.api.mdx index f9c7bd9b..5c9cca8a 100644 --- a/packages/docs/content/api/CDropdown.api.mdx +++ b/packages/docs/content/api/CDropdown.api.mdx @@ -11,7 +11,7 @@ import CDropdown from '@coreui/react/src/components/dropdown/CDropdown' | **as** | Component used for the root node. Either a string to use a HTML element or a component. | `(ElementType & 'symbol')` \| `(ElementType & 'object')` \| `(ElementType & 'div')` \| `(ElementType & 'slot')` \| `(ElementType & 'style')` \| `... 174 more ...` \| `(ElementType & FunctionComponent<...>)` | div | | **autoClose** | Configure the auto close behavior of the dropdown:
- `true` - the dropdown will be closed by clicking outside or inside the dropdown menu.
- `false` - the dropdown will be closed by clicking the toggle button and manually calling hide or toggle method. (Also will not be closed by pressing esc key)
- `'inside'` - the dropdown will be closed (only) by clicking inside the dropdown menu.
- `'outside'` - the dropdown will be closed (only) by clicking outside the dropdown menu. | `boolean` \| `'inside'` \| `'outside'` | true | | **className** | A string of all className you want applied to the base component. | `string` | - | -| **container** **_v4.11.0+_** | Appends the react dropdown menu to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `(() => Element)` | - | +| **container** **_v4.11.0+_** | Appends the react dropdown menu to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `DocumentFragment` \| `(() => Element` \| `DocumentFragment)` | - | | **dark** | Sets a darker color scheme to match a dark navbar. | `boolean` | - | | **direction** | Sets a specified direction and location of the dropdown menu. | `'center'` \| `'dropup'` \| `'dropup-center'` \| `'dropend'` \| `'dropstart'` | - | | **offset** | Offset of the dropdown menu relative to its target. | `[number, number]` | [0, 2] | diff --git a/packages/docs/content/api/CPopover.api.mdx b/packages/docs/content/api/CPopover.api.mdx index 40ad6fb7..20a24dda 100644 --- a/packages/docs/content/api/CPopover.api.mdx +++ b/packages/docs/content/api/CPopover.api.mdx @@ -9,7 +9,7 @@ import CPopover from '@coreui/react/src/components/popover/CPopover' | --- | --- | --- | --- | | **animation** **_4.9.0+_** | Apply a CSS fade transition to the popover. | `boolean` | true | | **className** | A string of all className you want applied to the component. | `string` | - | -| **container** **_v4.11.0+_** | Appends the react popover to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `(() => Element)` | - | +| **container** **_v4.11.0+_** | Appends the react popover to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `DocumentFragment` \| `(() => Element` \| `DocumentFragment)` | - | | **content** | Content node for your component. | `ReactNode` | - | | **delay** **_4.9.0+_** | The delay for displaying and hiding the popover (in milliseconds). When a numerical value is provided, the delay applies to both the hide and show actions. The object structure for specifying the delay is as follows: delay: `{ 'show': 500, 'hide': 100 }`. | `number` \| `{ show: number; hide: number; }` | 0 | | **fallbackPlacements** **_4.9.0+_** | Specify the desired order of fallback placements by providing a list of placements as an array. The placements should be prioritized based on preference. | `Placements` \| `Placements[]` | ['top', 'right', 'bottom', 'left'] | diff --git a/packages/docs/content/api/CTooltip.api.mdx b/packages/docs/content/api/CTooltip.api.mdx index 047a8ff8..54866f1a 100644 --- a/packages/docs/content/api/CTooltip.api.mdx +++ b/packages/docs/content/api/CTooltip.api.mdx @@ -9,7 +9,7 @@ import CTooltip from '@coreui/react/src/components/tooltip/CTooltip' | --- | --- | --- | --- | | **animation** **_4.9.0+_** | Apply a CSS fade transition to the tooltip. | `boolean` | true | | **className** | A string of all className you want applied to the component. | `string` | - | -| **container** **_v4.11.0+_** | Appends the react tooltip to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `(() => Element)` | - | +| **container** **_v4.11.0+_** | Appends the react tooltip to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `DocumentFragment` \| `(() => Element` \| `DocumentFragment)` | - | | **content** | Content node for your component. | `ReactNode` | - | | **delay** **_4.9.0+_** | The delay for displaying and hiding the tooltip (in milliseconds). When a numerical value is provided, the delay applies to both the hide and show actions. The object structure for specifying the delay is as follows: delay: `{ 'show': 500, 'hide': 100 }`. | `number` \| `{ show: number; hide: number; }` | 0 | | **fallbackPlacements** **_4.9.0+_** | Specify the desired order of fallback placements by providing a list of placements as an array. The placements should be prioritized based on preference. | `Placements` \| `Placements[]` | ['top', 'right', 'bottom', 'left'] | From 9e2ece494c43c4c66ff88034c5ccf08ba0621b41 Mon Sep 17 00:00:00 2001 From: mrholek Date: Fri, 2 Aug 2024 13:25:15 +0200 Subject: [PATCH 004/116] build: update globby to v14.x --- packages/docs/build/{api.js => api.mjs} | 30 +++++++++++++------------ packages/docs/package.json | 5 ++--- 2 files changed, 18 insertions(+), 17 deletions(-) rename packages/docs/build/{api.js => api.mjs} (83%) diff --git a/packages/docs/build/api.js b/packages/docs/build/api.mjs similarity index 83% rename from packages/docs/build/api.js rename to packages/docs/build/api.mjs index 084599da..7d92602e 100644 --- a/packages/docs/build/api.js +++ b/packages/docs/build/api.mjs @@ -2,10 +2,13 @@ 'use strict' -const fs = require('node:fs').promises -const path = require('node:path') -const globby = require('globby') -const docgen = require('react-docgen-typescript') +import { globby } from 'globby' +import { writeFile } from 'node:fs/promises' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { parse } from 'react-docgen-typescript' + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) const GLOB = [ '**/src/**/*.tsx', @@ -79,9 +82,9 @@ async function createMdx(file, filename, name, props) { const deprecated = value.tags.deprecated ? ` **_Deprecated ${value.tags.deprecated}+_**` : '' const description = value.description || '-' const type = value.type - ? (value.type.name.includes('ReactElement') + ? value.type.name.includes('ReactElement') ? 'ReactElement' - : value.type.name) + : value.type.name : '' const defaultValue = value.defaultValue ? value.defaultValue.value.replace('undefined', '-') @@ -97,13 +100,11 @@ async function createMdx(file, filename, name, props) { index++ } - await fs - .writeFile(`content/api/${filename}.api.mdx`, content, { - encoding: 'utf8', - }) - .then(() => { - console.log(`File created: ${filename}.api.mdx`) - }) + await writeFile(`content/api/${filename}.api.mdx`, content, { + encoding: 'utf8', + }).then(() => { + console.log(`File created: ${filename}.api.mdx`) + }) } async function main() { @@ -113,7 +114,8 @@ async function main() { await Promise.all( files.map((file) => { console.log(file) - const props = docgen.parse(file, options) + // const props = docgen.parse(file, options) + const props = parse(file, options) if (props && typeof props[0] !== 'undefined') { const filename = path.basename(file, '.tsx') createMdx(file, filename, props[0].displayName, props[0].props) diff --git a/packages/docs/package.json b/packages/docs/package.json index 2846bbab..3c50456a 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -14,7 +14,7 @@ "license": "MIT", "author": "The CoreUI Team (https://github.com/orgs/coreui/people)", "scripts": { - "api": "rimraf \"content/api/*\" & node build/api.js", + "api": "rimraf \"content/api/*\" & node build/api.mjs", "build": "gatsby build", "develop": "gatsby develop", "dist": "run-s api build", @@ -48,8 +48,7 @@ "gatsby-remark-external-links": "^0.0.4", "gatsby-source-filesystem": "^5.13.1", "gatsby-transformer-sharp": "^5.13.1", - "glob": "^7.2.3", - "globby": "^11.1.0", + "globby": "^14.0.2", "prism-react-renderer": "^2.3.1", "prismjs": "^1.29.0", "prop-types": "^15.8.1", From 61da024ac054f5ff410a24e48ce2fe55cd34ce49 Mon Sep 17 00:00:00 2001 From: mrholek Date: Fri, 2 Aug 2024 13:42:18 +0200 Subject: [PATCH 005/116] chore: clean-up --- .../docs/content/api/CAccordionCollapse.api.mdx | 13 ------------- packages/docs/content/api/CTabsContext.api.mdx | 10 ---------- 2 files changed, 23 deletions(-) delete mode 100644 packages/docs/content/api/CAccordionCollapse.api.mdx delete mode 100644 packages/docs/content/api/CTabsContext.api.mdx diff --git a/packages/docs/content/api/CAccordionCollapse.api.mdx b/packages/docs/content/api/CAccordionCollapse.api.mdx deleted file mode 100644 index 55fdfd01..00000000 --- a/packages/docs/content/api/CAccordionCollapse.api.mdx +++ /dev/null @@ -1,13 +0,0 @@ - -```jsx -import { CAccordionCollapse } from '@coreui/react' -// or -import CAccordionCollapse from '@coreui/react/src/components/accordion/CAccordionCollapse' -``` - -| Property | Description | Type | Default | -| --- | --- | --- | --- | -| **className** | A string of all className you want applied to the base component. | `string` | - | -| **onHide** | Callback fired when the component requests to be hidden. | `() => void` | - | -| **onShow** | Callback fired when the component requests to be shown. | `() => void` | - | -| **visible** | Toggle the visibility of component. | `boolean` | - | diff --git a/packages/docs/content/api/CTabsContext.api.mdx b/packages/docs/content/api/CTabsContext.api.mdx deleted file mode 100644 index fc799c7c..00000000 --- a/packages/docs/content/api/CTabsContext.api.mdx +++ /dev/null @@ -1,10 +0,0 @@ - -```jsx -import { CTabsContext } from '@coreui/react' -// or -import CTabsContext from '@coreui/react/src/components/tabs/CTabsContext' -``` - -| Property | Description | Type | Default | -| --- | --- | --- | --- | -| **activeItemKey** | The active item key. | `string` \| `number` | - | From 400da159fae24bbbec31368a45bdf2add5012146 Mon Sep 17 00:00:00 2001 From: mrholek Date: Fri, 2 Aug 2024 13:42:27 +0200 Subject: [PATCH 006/116] chore: update dependencies and devDependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @docsearch/css ^3.6.0 → ^3.6.1 @testing-library/jest-dom ^6.4.6 → ^6.4.8 eslint-plugin-prettier ^5.1.3 → ^5.2.1 eslint-plugin-react ^7.34.3 → ^7.35.0 eslint-plugin-unicorn ^54.0.0 → ^55.0.0 gatsby ^5.13.6 → ^5.13.7 lerna ^8.1.6 → ^8.1.7 prettier ^3.3.2 → ^3.3.3 rimraf ^5.0.8 → ^6.0.1 rollup ^4.18.0 → ^4.19.2 sass ^1.77.6 → ^1.77.8 ts-jest ^29.1.5 → ^29.2.4 typescript ^5.5.3 → ^5.5.4 --- package.json | 10 +++++----- packages/coreui-react/package.json | 8 ++++---- packages/docs/package.json | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 2b78740b..c5b7df9c 100644 --- a/package.json +++ b/package.json @@ -26,13 +26,13 @@ "@typescript-eslint/parser": "^7.15.0", "eslint": "8.57.0", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-prettier": "^5.1.3", - "eslint-plugin-react": "^7.34.3", + "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-react": "^7.35.0", "eslint-plugin-react-hooks": "^4.6.2", - "eslint-plugin-unicorn": "^54.0.0", - "lerna": "^8.1.6", + "eslint-plugin-unicorn": "^55.0.0", + "lerna": "^8.1.7", "npm-run-all": "^4.1.5", - "prettier": "^3.3.2" + "prettier": "^3.3.3" }, "overrides": { "gatsby-remark-external-links": { diff --git a/packages/coreui-react/package.json b/packages/coreui-react/package.json index 74f11789..9241363b 100644 --- a/packages/coreui-react/package.json +++ b/packages/coreui-react/package.json @@ -49,7 +49,7 @@ "@rollup/plugin-commonjs": "^26.0.1", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-typescript": "^11.1.6", - "@testing-library/jest-dom": "^6.4.6", + "@testing-library/jest-dom": "^6.4.8", "@testing-library/react": "^16.0.0", "@types/jest": "^29.5.12", "@types/react": "18.3.3", @@ -62,10 +62,10 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-transition-group": "^4.4.5", - "rollup": "^4.18.0", - "ts-jest": "^29.1.5", + "rollup": "^4.19.2", + "ts-jest": "^29.2.4", "tslib": "^2.6.3", - "typescript": "^5.5.3" + "typescript": "^5.5.4" }, "peerDependencies": { "react": ">=17", diff --git a/packages/docs/package.json b/packages/docs/package.json index 3c50456a..e3f8a3ff 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -30,11 +30,11 @@ "@coreui/icons-react": "^2.3.0", "@coreui/react-chartjs": "^3.0.0", "@coreui/utils": "^2.0.2", - "@docsearch/css": "^3.6.0", + "@docsearch/css": "^3.6.1", "@mdx-js/mdx": "^3.0.1", "@mdx-js/react": "^3.0.1", "@types/react-helmet": "^6.1.11", - "gatsby": "^5.13.6", + "gatsby": "^5.13.7", "gatsby-plugin-google-tagmanager": "^5.13.1", "gatsby-plugin-image": "^3.13.1", "gatsby-plugin-manifest": "^5.13.1", @@ -57,8 +57,8 @@ "react-dom": "^18.3.1", "react-helmet": "^6.1.0", "react-imask": "^7.6.1", - "rimraf": "^5.0.8", - "sass": "^1.77.6" + "rimraf": "^6.0.1", + "sass": "^1.77.8" }, "devDependencies": { "npm-run-all": "^4.1.5" From c9f78f3c973c903a60402e5d783668bd507fcf0d Mon Sep 17 00:00:00 2001 From: mrholek Date: Fri, 2 Aug 2024 13:48:43 +0200 Subject: [PATCH 007/116] docs: update API documentation --- .../src/components/conditional-portal/CConditionalPortal.tsx | 2 +- packages/coreui-react/src/components/dropdown/CDropdown.tsx | 2 +- .../coreui-react/src/components/dropdown/CDropdownToggle.tsx | 2 +- packages/coreui-react/src/components/popover/CPopover.tsx | 2 +- packages/coreui-react/src/components/tooltip/CTooltip.tsx | 2 +- packages/docs/content/api/CConditionalPortal.api.mdx | 2 +- packages/docs/content/api/CDropdown.api.mdx | 2 +- packages/docs/content/api/CDropdownToggle.api.mdx | 2 +- packages/docs/content/api/CPopover.api.mdx | 2 +- packages/docs/content/api/CTooltip.api.mdx | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/coreui-react/src/components/conditional-portal/CConditionalPortal.tsx b/packages/coreui-react/src/components/conditional-portal/CConditionalPortal.tsx index 5e228b19..ca9bea8c 100644 --- a/packages/coreui-react/src/components/conditional-portal/CConditionalPortal.tsx +++ b/packages/coreui-react/src/components/conditional-portal/CConditionalPortal.tsx @@ -20,7 +20,7 @@ export interface CConditionalPortalProps { /** * An HTML element or function that returns a single element, with `document.body` as the default. * - * @since v4.11.0 + * @since 4.11.0 */ container?: DocumentFragment | Element | (() => DocumentFragment | Element | null) | null /** diff --git a/packages/coreui-react/src/components/dropdown/CDropdown.tsx b/packages/coreui-react/src/components/dropdown/CDropdown.tsx index 992691a3..076c1812 100644 --- a/packages/coreui-react/src/components/dropdown/CDropdown.tsx +++ b/packages/coreui-react/src/components/dropdown/CDropdown.tsx @@ -46,7 +46,7 @@ export interface CDropdownProps extends HTMLAttributes DocumentFragment | Element | null) | null /** diff --git a/packages/coreui-react/src/components/dropdown/CDropdownToggle.tsx b/packages/coreui-react/src/components/dropdown/CDropdownToggle.tsx index 68c1cdef..3d7ce44c 100644 --- a/packages/coreui-react/src/components/dropdown/CDropdownToggle.tsx +++ b/packages/coreui-react/src/components/dropdown/CDropdownToggle.tsx @@ -21,7 +21,7 @@ export interface CDropdownToggleProps extends Omit { /** * If a dropdown `variant` is set to `nav-item` then render the toggler as a link instead of a button. * - * @since v5.0.0 + * @since 5.0.0 */ navLink?: boolean /** diff --git a/packages/coreui-react/src/components/popover/CPopover.tsx b/packages/coreui-react/src/components/popover/CPopover.tsx index 2abd14c8..1ed3393d 100644 --- a/packages/coreui-react/src/components/popover/CPopover.tsx +++ b/packages/coreui-react/src/components/popover/CPopover.tsx @@ -22,7 +22,7 @@ export interface CPopoverProps extends Omit, 'tit /** * Appends the react popover to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. * - * @since v4.11.0 + * @since 4.11.0 */ container?: DocumentFragment | Element | (() => DocumentFragment | Element | null) | null /** diff --git a/packages/coreui-react/src/components/tooltip/CTooltip.tsx b/packages/coreui-react/src/components/tooltip/CTooltip.tsx index 61891f64..b971674f 100644 --- a/packages/coreui-react/src/components/tooltip/CTooltip.tsx +++ b/packages/coreui-react/src/components/tooltip/CTooltip.tsx @@ -22,7 +22,7 @@ export interface CTooltipProps extends Omit, 'con /** * Appends the react tooltip to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. * - * @since v4.11.0 + * @since 4.11.0 */ container?: DocumentFragment | Element | (() => DocumentFragment | Element | null) | null /** diff --git a/packages/docs/content/api/CConditionalPortal.api.mdx b/packages/docs/content/api/CConditionalPortal.api.mdx index 3817d616..9a90013e 100644 --- a/packages/docs/content/api/CConditionalPortal.api.mdx +++ b/packages/docs/content/api/CConditionalPortal.api.mdx @@ -7,5 +7,5 @@ import CConditionalPortal from '@coreui/react/src/components/conditional-portal/ | Property | Description | Type | Default | | --- | --- | --- | --- | -| **container** **_v4.11.0+_** | An HTML element or function that returns a single element, with `document.body` as the default. | `DocumentFragment` \| `Element` \| `(() => DocumentFragment` \| `Element)` | - | +| **container** **_4.11.0+_** | An HTML element or function that returns a single element, with `document.body` as the default. | `DocumentFragment` \| `Element` \| `(() => DocumentFragment` \| `Element)` | - | | **portal** | Render some children into a different part of the DOM | `boolean` | - | diff --git a/packages/docs/content/api/CDropdown.api.mdx b/packages/docs/content/api/CDropdown.api.mdx index 5c9cca8a..80106e4d 100644 --- a/packages/docs/content/api/CDropdown.api.mdx +++ b/packages/docs/content/api/CDropdown.api.mdx @@ -11,7 +11,7 @@ import CDropdown from '@coreui/react/src/components/dropdown/CDropdown' | **as** | Component used for the root node. Either a string to use a HTML element or a component. | `(ElementType & 'symbol')` \| `(ElementType & 'object')` \| `(ElementType & 'div')` \| `(ElementType & 'slot')` \| `(ElementType & 'style')` \| `... 174 more ...` \| `(ElementType & FunctionComponent<...>)` | div | | **autoClose** | Configure the auto close behavior of the dropdown:
- `true` - the dropdown will be closed by clicking outside or inside the dropdown menu.
- `false` - the dropdown will be closed by clicking the toggle button and manually calling hide or toggle method. (Also will not be closed by pressing esc key)
- `'inside'` - the dropdown will be closed (only) by clicking inside the dropdown menu.
- `'outside'` - the dropdown will be closed (only) by clicking outside the dropdown menu. | `boolean` \| `'inside'` \| `'outside'` | true | | **className** | A string of all className you want applied to the base component. | `string` | - | -| **container** **_v4.11.0+_** | Appends the react dropdown menu to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `DocumentFragment` \| `(() => Element` \| `DocumentFragment)` | - | +| **container** **_4.11.0+_** | Appends the react dropdown menu to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `DocumentFragment` \| `(() => Element` \| `DocumentFragment)` | - | | **dark** | Sets a darker color scheme to match a dark navbar. | `boolean` | - | | **direction** | Sets a specified direction and location of the dropdown menu. | `'center'` \| `'dropup'` \| `'dropup-center'` \| `'dropend'` \| `'dropstart'` | - | | **offset** | Offset of the dropdown menu relative to its target. | `[number, number]` | [0, 2] | diff --git a/packages/docs/content/api/CDropdownToggle.api.mdx b/packages/docs/content/api/CDropdownToggle.api.mdx index cdc7d534..7a4ecef2 100644 --- a/packages/docs/content/api/CDropdownToggle.api.mdx +++ b/packages/docs/content/api/CDropdownToggle.api.mdx @@ -15,7 +15,7 @@ import CDropdownToggle from '@coreui/react/src/components/dropdown/CDropdownTogg | **custom** | Create a custom toggler which accepts any content. | `boolean` | - | | **disabled** | Toggle the disabled state for the component. | `boolean` | - | | **href** | The href attribute specifies the URL of the page the link goes to. | `string` | - | -| **navLink** **_v5.0.0+_** | If a dropdown `variant` is set to `nav-item` then render the toggler as a link instead of a button. | `boolean` | true | +| **navLink** **_5.0.0+_** | If a dropdown `variant` is set to `nav-item` then render the toggler as a link instead of a button. | `boolean` | true | | **role** | The role attribute describes the role of an element in programs that can make use of it, such as screen readers or magnifiers. | `string` | - | | **shape** | Select the shape of the component. | `'rounded'` \| `'rounded-top'` \| `'rounded-end'` \| `'rounded-bottom'` \| `'rounded-start'` \| `'rounded-circle'` \| `'rounded-pill'` \| `'rounded-0'` \| `'rounded-1'` \| `'rounded-2'` \| `'rounded-3'` \| `string` | - | | **size** | Size the component small or large. | `'sm'` \| `'lg'` | - | diff --git a/packages/docs/content/api/CPopover.api.mdx b/packages/docs/content/api/CPopover.api.mdx index 20a24dda..c850d297 100644 --- a/packages/docs/content/api/CPopover.api.mdx +++ b/packages/docs/content/api/CPopover.api.mdx @@ -9,7 +9,7 @@ import CPopover from '@coreui/react/src/components/popover/CPopover' | --- | --- | --- | --- | | **animation** **_4.9.0+_** | Apply a CSS fade transition to the popover. | `boolean` | true | | **className** | A string of all className you want applied to the component. | `string` | - | -| **container** **_v4.11.0+_** | Appends the react popover to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `DocumentFragment` \| `(() => Element` \| `DocumentFragment)` | - | +| **container** **_4.11.0+_** | Appends the react popover to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `DocumentFragment` \| `(() => Element` \| `DocumentFragment)` | - | | **content** | Content node for your component. | `ReactNode` | - | | **delay** **_4.9.0+_** | The delay for displaying and hiding the popover (in milliseconds). When a numerical value is provided, the delay applies to both the hide and show actions. The object structure for specifying the delay is as follows: delay: `{ 'show': 500, 'hide': 100 }`. | `number` \| `{ show: number; hide: number; }` | 0 | | **fallbackPlacements** **_4.9.0+_** | Specify the desired order of fallback placements by providing a list of placements as an array. The placements should be prioritized based on preference. | `Placements` \| `Placements[]` | ['top', 'right', 'bottom', 'left'] | diff --git a/packages/docs/content/api/CTooltip.api.mdx b/packages/docs/content/api/CTooltip.api.mdx index 54866f1a..37d86e6c 100644 --- a/packages/docs/content/api/CTooltip.api.mdx +++ b/packages/docs/content/api/CTooltip.api.mdx @@ -9,7 +9,7 @@ import CTooltip from '@coreui/react/src/components/tooltip/CTooltip' | --- | --- | --- | --- | | **animation** **_4.9.0+_** | Apply a CSS fade transition to the tooltip. | `boolean` | true | | **className** | A string of all className you want applied to the component. | `string` | - | -| **container** **_v4.11.0+_** | Appends the react tooltip to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `DocumentFragment` \| `(() => Element` \| `DocumentFragment)` | - | +| **container** **_4.11.0+_** | Appends the react tooltip to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`. | `Element` \| `DocumentFragment` \| `(() => Element` \| `DocumentFragment)` | - | | **content** | Content node for your component. | `ReactNode` | - | | **delay** **_4.9.0+_** | The delay for displaying and hiding the tooltip (in milliseconds). When a numerical value is provided, the delay applies to both the hide and show actions. The object structure for specifying the delay is as follows: delay: `{ 'show': 500, 'hide': 100 }`. | `number` \| `{ show: number; hide: number; }` | 0 | | **fallbackPlacements** **_4.9.0+_** | Specify the desired order of fallback placements by providing a list of placements as an array. The placements should be prioritized based on preference. | `Placements` \| `Placements[]` | ['top', 'right', 'bottom', 'left'] | From 689285835f2d03884b01cc2c777df082b067b434 Mon Sep 17 00:00:00 2001 From: mrholek Date: Fri, 2 Aug 2024 13:52:14 +0200 Subject: [PATCH 008/116] release: v5.3.0 --- README.md | 2 +- lerna.json | 2 +- packages/coreui-react/README.md | 2 +- packages/coreui-react/package.json | 2 +- packages/docs/package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4b1884c3..26d6b460 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Several quick start options are available: -- [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.2.0.zip) +- [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.3.0.zip) - Clone the repo: `git clone https://github.com/coreui/coreui-react.git` - Install with [npm](https://www.npmjs.com/): `npm install @coreui/react` - Install with [yarn](https://yarnpkg.com/): `yarn add @coreui/react` diff --git a/lerna.json b/lerna.json index f19238c5..8e4098d4 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "npmClient": "yarn", "packages": ["packages/*"], - "version": "5.2.0", + "version": "5.3.0", "$schema": "node_modules/lerna/schemas/lerna-schema.json" } diff --git a/packages/coreui-react/README.md b/packages/coreui-react/README.md index 60d8b83c..95934c20 100644 --- a/packages/coreui-react/README.md +++ b/packages/coreui-react/README.md @@ -46,7 +46,7 @@ Several quick start options are available: -- [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.2.0.zip) +- [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.3.0.zip) - Clone the repo: `git clone https://github.com/coreui/coreui-react.git` - Install with [npm](https://www.npmjs.com/): `npm install @coreui/react` - Install with [yarn](https://yarnpkg.com/): `yarn add @coreui/react` diff --git a/packages/coreui-react/package.json b/packages/coreui-react/package.json index 9241363b..9a9accca 100644 --- a/packages/coreui-react/package.json +++ b/packages/coreui-react/package.json @@ -1,6 +1,6 @@ { "name": "@coreui/react", - "version": "5.2.0", + "version": "5.3.0", "description": "UI Components Library for React.js", "keywords": [ "react", diff --git a/packages/docs/package.json b/packages/docs/package.json index e3f8a3ff..a0e3a101 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -1,6 +1,6 @@ { "name": "@coreui/react-docs", - "version": "5.2.0", + "version": "5.3.0", "private": true, "description": "", "homepage": "https://coreui.io/react/", From 8b25a39b2618ca088cb84d7c176a94e32a614084 Mon Sep 17 00:00:00 2001 From: Jasper <8398131+jasperfirecai2@users.noreply.github.com> Date: Fri, 16 Aug 2024 12:56:57 +0200 Subject: [PATCH 009/116] fix special key prop in CToast --- packages/coreui-react/src/components/toast/CToast.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/coreui-react/src/components/toast/CToast.tsx b/packages/coreui-react/src/components/toast/CToast.tsx index 449daaea..acc405b3 100644 --- a/packages/coreui-react/src/components/toast/CToast.tsx +++ b/packages/coreui-react/src/components/toast/CToast.tsx @@ -44,7 +44,7 @@ export interface CToastProps extends Omit, 'title /** * @ignore */ - key?: number + innerKey?: number | string /** * Callback fired when the component requests to be closed. */ @@ -76,7 +76,7 @@ export const CToast = forwardRef( color, delay = 5000, index, - key, + innerKey, visible = false, onClose, onShow, @@ -143,7 +143,7 @@ export const CToast = forwardRef( onMouseEnter={() => clearTimeout(timeout.current)} onMouseLeave={() => _autohide()} {...rest} - key={key} + key={innerKey} ref={forkedRef} > {children} @@ -163,7 +163,10 @@ CToast.propTypes = { color: colorPropType, delay: PropTypes.number, index: PropTypes.number, - key: PropTypes.number, + innerKey: PropTypes.oneOfType([ + PropTypes.number, + PropTypes.string + ]), onClose: PropTypes.func, onShow: PropTypes.func, visible: PropTypes.bool, From 71e13d8b4c0a989732c823ea1df2c6b00e96a790 Mon Sep 17 00:00:00 2001 From: mrholek Date: Fri, 23 Aug 2024 17:46:42 +0200 Subject: [PATCH 010/116] fix(CFormSelect): add the missing `selected` attribute to the option typings --- packages/coreui-react/src/components/form/CFormSelect.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/coreui-react/src/components/form/CFormSelect.tsx b/packages/coreui-react/src/components/form/CFormSelect.tsx index af0b2d72..42527495 100644 --- a/packages/coreui-react/src/components/form/CFormSelect.tsx +++ b/packages/coreui-react/src/components/form/CFormSelect.tsx @@ -7,6 +7,7 @@ import { CFormControlWrapper, CFormControlWrapperProps } from './CFormControlWra type Option = { disabled?: boolean label?: string + selected?: boolean value?: string } From 785ecc8b6fa462abf7212cc163aabe4fa8f3bc2f Mon Sep 17 00:00:00 2001 From: Jasper <8398131+jasperfirecai2@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:36:04 +0200 Subject: [PATCH 011/116] FIx crow not passing props --- packages/coreui-react/src/components/grid/CRow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/coreui-react/src/components/grid/CRow.tsx b/packages/coreui-react/src/components/grid/CRow.tsx index 14800d5e..ee2af420 100644 --- a/packages/coreui-react/src/components/grid/CRow.tsx +++ b/packages/coreui-react/src/components/grid/CRow.tsx @@ -91,7 +91,7 @@ export const CRow = forwardRef( }) return ( -
+
{children}
) From b2831a29cb9c1356126cd96421cae4ee60fad86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Holeczek?= Date: Wed, 18 Sep 2024 21:23:16 +0200 Subject: [PATCH 012/116] Update CRow.tsx --- packages/coreui-react/src/components/grid/CRow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/coreui-react/src/components/grid/CRow.tsx b/packages/coreui-react/src/components/grid/CRow.tsx index ee2af420..05a54711 100644 --- a/packages/coreui-react/src/components/grid/CRow.tsx +++ b/packages/coreui-react/src/components/grid/CRow.tsx @@ -91,7 +91,7 @@ export const CRow = forwardRef( }) return ( -
+
{children}
) From 57cfe9e0315d6d56fc4902e2368fc0cf1041075e Mon Sep 17 00:00:00 2001 From: mrholek Date: Wed, 18 Sep 2024 21:32:03 +0200 Subject: [PATCH 013/116] fix(CTabs): add missing `disabled` prop --- packages/coreui-react/src/components/tabs/CTab.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/coreui-react/src/components/tabs/CTab.tsx b/packages/coreui-react/src/components/tabs/CTab.tsx index 63a8dbbe..88e892d7 100644 --- a/packages/coreui-react/src/components/tabs/CTab.tsx +++ b/packages/coreui-react/src/components/tabs/CTab.tsx @@ -9,6 +9,10 @@ export interface CTabProps extends HTMLAttributes { * A string of all className you want applied to the base component. */ className?: string + /** + * Toggle the disabled state for the component. + */ + disabled?: boolean /** * Item key. */ @@ -50,6 +54,7 @@ export const CTab = forwardRef( CTab.propTypes = { children: PropTypes.node, className: PropTypes.string, + disabled: PropTypes.bool, itemKey: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired, } From 786399c2a567ba22a37797b98767c624c5c28ab3 Mon Sep 17 00:00:00 2001 From: Jasperfirecai2 <8398131+jasperfirecai2@users.noreply.github.com> Date: Wed, 18 Sep 2024 21:58:44 +0200 Subject: [PATCH 014/116] Update key to innerkey in toaster --- packages/coreui-react/src/components/toast/CToaster.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/coreui-react/src/components/toast/CToaster.tsx b/packages/coreui-react/src/components/toast/CToaster.tsx index e7d41e76..7ad9b823 100644 --- a/packages/coreui-react/src/components/toast/CToaster.tsx +++ b/packages/coreui-react/src/components/toast/CToaster.tsx @@ -45,7 +45,7 @@ export const CToaster = forwardRef( ...state, React.cloneElement(push, { index: index.current, - key: index.current, + innerKey: index.current, onClose: (index: number) => setToasts((state) => state.filter((i) => i.props.index !== index)), }), From 67106fb24518caac71e830bf67adf9a466d199c9 Mon Sep 17 00:00:00 2001 From: mrholek Date: Wed, 18 Sep 2024 23:07:22 +0200 Subject: [PATCH 015/116] fix(CTabs): add missing `disabled` prop --- packages/docs/content/api/CTab.api.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/docs/content/api/CTab.api.mdx b/packages/docs/content/api/CTab.api.mdx index f0ba1fe6..9a9835e5 100644 --- a/packages/docs/content/api/CTab.api.mdx +++ b/packages/docs/content/api/CTab.api.mdx @@ -8,4 +8,5 @@ import CTab from '@coreui/react/src/components/tabs/CTab' | Property | Description | Type | Default | | --- | --- | --- | --- | | **className** | A string of all className you want applied to the base component. | `string` | - | +| **disabled** | Toggle the disabled state for the component. | `boolean` | - | | **itemKey** | Item key. | `string` \| `number` | - | From b5782510e7004f5dd3379db63945ca5b961666a8 Mon Sep 17 00:00:00 2001 From: mrholek Date: Wed, 18 Sep 2024 23:39:14 +0200 Subject: [PATCH 016/116] feat(CBreadcrumb): allow to pass custom components as breadcrumb item --- .../components/breadcrumb/CBreadcrumbItem.tsx | 57 ++++++++++++------- .../docs/content/api/CBreadcrumbItem.api.mdx | 1 + 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/packages/coreui-react/src/components/breadcrumb/CBreadcrumbItem.tsx b/packages/coreui-react/src/components/breadcrumb/CBreadcrumbItem.tsx index 153ca479..fab4ec69 100644 --- a/packages/coreui-react/src/components/breadcrumb/CBreadcrumbItem.tsx +++ b/packages/coreui-react/src/components/breadcrumb/CBreadcrumbItem.tsx @@ -1,14 +1,22 @@ -import React, { forwardRef, HTMLAttributes } from 'react' +import React, { ElementType, forwardRef, HTMLAttributes } from 'react' import PropTypes from 'prop-types' import classNames from 'classnames' import { CLink } from '../link/CLink' +import { PolymorphicRefForwardingComponent } from '../../helpers' + export interface CBreadcrumbItemProps extends HTMLAttributes { /** * Toggle the active state for the component. */ active?: boolean + /** + * Component used for the root node. Either a string to use a HTML element or a component. + * + * @since 5.4.0 + */ + as?: ElementType /** * A string of all className you want applied to the base component. */ @@ -19,26 +27,33 @@ export interface CBreadcrumbItemProps extends HTMLAttributes { href?: string } -export const CBreadcrumbItem = forwardRef( - ({ children, active, className, href, ...rest }, ref) => { - return ( -
  • - {href ? {children} : children} -
  • - ) - }, -) +export const CBreadcrumbItem: PolymorphicRefForwardingComponent<'li', CBreadcrumbItemProps> = + forwardRef( + ({ children, active, as, className, href, ...rest }, ref) => { + return ( +
  • + {href ? ( + + {children} + + ) : ( + children + )} +
  • + ) + }, + ) CBreadcrumbItem.propTypes = { active: PropTypes.bool, diff --git a/packages/docs/content/api/CBreadcrumbItem.api.mdx b/packages/docs/content/api/CBreadcrumbItem.api.mdx index 431f6fb3..e3b91512 100644 --- a/packages/docs/content/api/CBreadcrumbItem.api.mdx +++ b/packages/docs/content/api/CBreadcrumbItem.api.mdx @@ -8,5 +8,6 @@ import CBreadcrumbItem from '@coreui/react/src/components/breadcrumb/CBreadcrumb | Property | Description | Type | Default | | --- | --- | --- | --- | | **active** | Toggle the active state for the component. | `boolean` | - | +| **as** **_5.4.0+_** | Component used for the root node. Either a string to use a HTML element or a component. | `(ElementType & 'symbol')` \| `(ElementType & 'object')` \| `(ElementType & 'li')` \| `(ElementType & 'slot')` \| `(ElementType & 'style')` \| `... 174 more ...` \| `(ElementType & FunctionComponent<...>)` | - | | **className** | A string of all className you want applied to the base component. | `string` | - | | **href** | The `href` attribute for the inner `` component. | `string` | - | From e48c09f80a2de7c608268c4ffedf1128d5527396 Mon Sep 17 00:00:00 2001 From: mrholek Date: Sun, 22 Sep 2024 14:15:16 +0200 Subject: [PATCH 017/116] chore: update dependencies and devDependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @coreui/coreui ^5.1.0 → ^5.1.2 @typescript-eslint/eslint-plugin ^7.15.0 → ^8.6.0 @typescript-eslint/parser ^7.15.0 → ^8.6.0 @testing-library/jest-dom ^6.4.8 → ^6.5.0 @testing-library/react ^16.0.0 → ^16.0.1 @types/jest ^29.5.12 → ^29.5.13 @types/react 18.3.3 → 18.3.8 @types/react-transition-group ^4.4.10 → ^4.4.11 eslint-plugin-react ^7.35.0 → ^7.36.1 gatsby-plugin-offline ^6.13.2 → ^6.13.3 lerna ^8.1.7 → ^8.1.8 prism-react-renderer ^2.3.1 → ^2.4.0 rollup ^4.19.2 → ^4.22.4 sass ^1.77.8 → ^1.79.3 ts-jest ^29.2.4 → ^29.2.5 tslib ^2.6.3 → ^2.7.0 typescript ^5.5.4 → ^5.6.2 --- package.json | 8 ++++---- packages/coreui-react/package.json | 20 ++++++++++---------- packages/docs/package.json | 8 ++++---- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index c5b7df9c..e9ecc32b 100644 --- a/package.json +++ b/package.json @@ -22,15 +22,15 @@ "test:update": "npm-run-all charts:test:update icons:test:update lib:test:update" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^7.15.0", - "@typescript-eslint/parser": "^7.15.0", + "@typescript-eslint/eslint-plugin": "^8.6.0", + "@typescript-eslint/parser": "^8.6.0", "eslint": "8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", - "eslint-plugin-react": "^7.35.0", + "eslint-plugin-react": "^7.36.1", "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-unicorn": "^55.0.0", - "lerna": "^8.1.7", + "lerna": "^8.1.8", "npm-run-all": "^4.1.5", "prettier": "^3.3.3" }, diff --git a/packages/coreui-react/package.json b/packages/coreui-react/package.json index 9a9accca..2a2f21ba 100644 --- a/packages/coreui-react/package.json +++ b/packages/coreui-react/package.json @@ -41,7 +41,7 @@ "test:update": "jest --coverage --updateSnapshot" }, "dependencies": { - "@coreui/coreui": "^5.1.0", + "@coreui/coreui": "^5.1.2", "@popperjs/core": "^2.11.8", "prop-types": "^15.8.1" }, @@ -49,12 +49,12 @@ "@rollup/plugin-commonjs": "^26.0.1", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-typescript": "^11.1.6", - "@testing-library/jest-dom": "^6.4.8", - "@testing-library/react": "^16.0.0", - "@types/jest": "^29.5.12", - "@types/react": "18.3.3", + "@testing-library/jest-dom": "^6.5.0", + "@testing-library/react": "^16.0.1", + "@types/jest": "^29.5.13", + "@types/react": "18.3.8", "@types/react-dom": "^18.3.0", - "@types/react-transition-group": "^4.4.10", + "@types/react-transition-group": "^4.4.11", "classnames": "^2.5.1", "cross-env": "^7.0.3", "jest": "^29.7.0", @@ -62,10 +62,10 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-transition-group": "^4.4.5", - "rollup": "^4.19.2", - "ts-jest": "^29.2.4", - "tslib": "^2.6.3", - "typescript": "^5.5.4" + "rollup": "^4.22.4", + "ts-jest": "^29.2.5", + "tslib": "^2.7.0", + "typescript": "^5.6.2" }, "peerDependencies": { "react": ">=17", diff --git a/packages/docs/package.json b/packages/docs/package.json index a0e3a101..667a23ab 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -25,7 +25,7 @@ }, "dependencies": { "@coreui/chartjs": "^4.0.0", - "@coreui/coreui": "^5.1.0", + "@coreui/coreui": "^5.1.2", "@coreui/icons": "^3.0.1", "@coreui/icons-react": "^2.3.0", "@coreui/react-chartjs": "^3.0.0", @@ -39,7 +39,7 @@ "gatsby-plugin-image": "^3.13.1", "gatsby-plugin-manifest": "^5.13.1", "gatsby-plugin-mdx": "^5.13.1", - "gatsby-plugin-offline": "^6.13.2", + "gatsby-plugin-offline": "^6.13.3", "gatsby-plugin-react-helmet": "^6.13.1", "gatsby-plugin-sass": "^6.13.1", "gatsby-plugin-sharp": "^5.13.1", @@ -49,7 +49,7 @@ "gatsby-source-filesystem": "^5.13.1", "gatsby-transformer-sharp": "^5.13.1", "globby": "^14.0.2", - "prism-react-renderer": "^2.3.1", + "prism-react-renderer": "^2.4.0", "prismjs": "^1.29.0", "prop-types": "^15.8.1", "react": "^18.3.1", @@ -58,7 +58,7 @@ "react-helmet": "^6.1.0", "react-imask": "^7.6.1", "rimraf": "^6.0.1", - "sass": "^1.77.8" + "sass": "^1.79.3" }, "devDependencies": { "npm-run-all": "^4.1.5" From 5612934329a8882cd17855c688accaf236f5a6a8 Mon Sep 17 00:00:00 2001 From: mrholek Date: Sun, 22 Sep 2024 17:35:57 +0200 Subject: [PATCH 018/116] release: v5.4.0 --- README.md | 2 +- lerna.json | 2 +- packages/coreui-react/README.md | 2 +- packages/coreui-react/package.json | 2 +- packages/docs/package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 26d6b460..f50b90dc 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Several quick start options are available: -- [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.3.0.zip) +- [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.4.0.zip) - Clone the repo: `git clone https://github.com/coreui/coreui-react.git` - Install with [npm](https://www.npmjs.com/): `npm install @coreui/react` - Install with [yarn](https://yarnpkg.com/): `yarn add @coreui/react` diff --git a/lerna.json b/lerna.json index 8e4098d4..a5830df9 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "npmClient": "yarn", "packages": ["packages/*"], - "version": "5.3.0", + "version": "5.4.0", "$schema": "node_modules/lerna/schemas/lerna-schema.json" } diff --git a/packages/coreui-react/README.md b/packages/coreui-react/README.md index 95934c20..3817c711 100644 --- a/packages/coreui-react/README.md +++ b/packages/coreui-react/README.md @@ -46,7 +46,7 @@ Several quick start options are available: -- [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.3.0.zip) +- [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.4.0.zip) - Clone the repo: `git clone https://github.com/coreui/coreui-react.git` - Install with [npm](https://www.npmjs.com/): `npm install @coreui/react` - Install with [yarn](https://yarnpkg.com/): `yarn add @coreui/react` diff --git a/packages/coreui-react/package.json b/packages/coreui-react/package.json index 2a2f21ba..ac389697 100644 --- a/packages/coreui-react/package.json +++ b/packages/coreui-react/package.json @@ -1,6 +1,6 @@ { "name": "@coreui/react", - "version": "5.3.0", + "version": "5.4.0", "description": "UI Components Library for React.js", "keywords": [ "react", diff --git a/packages/docs/package.json b/packages/docs/package.json index 667a23ab..31890153 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -1,6 +1,6 @@ { "name": "@coreui/react-docs", - "version": "5.3.0", + "version": "5.4.0", "private": true, "description": "", "homepage": "https://coreui.io/react/", From 4f3979a3434f05c1b4d06066d9939b4baad3fee8 Mon Sep 17 00:00:00 2001 From: Jasper <8398131+jasperfirecai2@users.noreply.github.com> Date: Thu, 26 Sep 2024 12:43:56 +0200 Subject: [PATCH 019/116] fix(CNavGroup): set default `height` state to 0 --- packages/coreui-react/src/components/nav/CNavGroup.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/coreui-react/src/components/nav/CNavGroup.tsx b/packages/coreui-react/src/components/nav/CNavGroup.tsx index 776bf104..5a7d891e 100644 --- a/packages/coreui-react/src/components/nav/CNavGroup.tsx +++ b/packages/coreui-react/src/components/nav/CNavGroup.tsx @@ -58,7 +58,7 @@ export const CNavGroup: PolymorphicRefForwardingComponent<'li', CNavGroupProps> HTMLDivElement | HTMLLIElement, CNavGroupProps >(({ children, as: Component = 'li', className, compact, idx, toggler, visible, ...rest }, ref) => { - const [height, setHeight] = useState() + const [height, setHeight] = useState(0) // eslint-disable-next-line @typescript-eslint/no-explicit-any const navItemsRef = useRef(null) From 9265cb446755156989dde6cbb4a146dae89009a0 Mon Sep 17 00:00:00 2001 From: Danikokonn Date: Thu, 10 Oct 2024 15:24:00 +0300 Subject: [PATCH 020/116] FIx CListGroup not passing props --- packages/coreui-react/src/components/list-group/CListGroup.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/coreui-react/src/components/list-group/CListGroup.tsx b/packages/coreui-react/src/components/list-group/CListGroup.tsx index becc64dd..1dce9007 100644 --- a/packages/coreui-react/src/components/list-group/CListGroup.tsx +++ b/packages/coreui-react/src/components/list-group/CListGroup.tsx @@ -32,7 +32,7 @@ export interface CListGroupProps extends HTMLAttributes = forwardRef< HTMLDivElement | HTMLUListElement, CListGroupProps ->(({ children, as: Component = 'ul', className, flush, layout }, ref) => { +>(({ children, as: Component = 'ul', className, flush, layout, ...rest }, ref) => { return ( {children} From a93c502756003bfd3c722075cffa086e5594bc1b Mon Sep 17 00:00:00 2001 From: mrholek Date: Tue, 29 Oct 2024 00:26:57 +0100 Subject: [PATCH 021/116] refactor(CPopover, CTooltip): improve fade animation --- .../src/components/popover/CPopover.tsx | 111 ++++++++++-------- .../src/components/tooltip/CTooltip.tsx | 111 ++++++++++-------- 2 files changed, 130 insertions(+), 92 deletions(-) diff --git a/packages/coreui-react/src/components/popover/CPopover.tsx b/packages/coreui-react/src/components/popover/CPopover.tsx index 1ed3393d..d6210f73 100644 --- a/packages/coreui-react/src/components/popover/CPopover.tsx +++ b/packages/coreui-react/src/components/popover/CPopover.tsx @@ -1,4 +1,12 @@ -import React, { forwardRef, HTMLAttributes, ReactNode, useRef, useEffect, useState } from 'react' +import React, { + forwardRef, + HTMLAttributes, + ReactNode, + useEffect, + useId, + useRef, + useState, +} from 'react' import classNames from 'classnames' import PropTypes from 'prop-types' @@ -97,12 +105,13 @@ export const CPopover = forwardRef( const popoverRef = useRef(null) const togglerRef = useRef(null) const forkedRef = useForkedRef(ref, popoverRef) - const uID = useRef(`popover${Math.floor(Math.random() * 1_000_000)}`) - const { initPopper, destroyPopper } = usePopper() + const id = `popover${useId()}` const [mounted, setMounted] = useState(false) const [_visible, setVisible] = useState(visible) + const { initPopper, destroyPopper } = usePopper() + const _delay = typeof delay === 'number' ? { show: delay, hide: delay } : delay const popperConfig = { @@ -130,77 +139,87 @@ export const CPopover = forwardRef( } useEffect(() => { - setVisible(visible) + if (visible) { + handleShow() + return + } + + handleHide() }, [visible]) useEffect(() => { - if (_visible) { - setMounted(true) - - if (popoverRef.current) { - popoverRef.current.classList.remove('fade', 'show') - destroyPopper() - } - + if (mounted && togglerRef.current && popoverRef.current) { + initPopper(togglerRef.current, popoverRef.current, popperConfig) setTimeout(() => { - if (togglerRef.current && popoverRef.current) { - if (animation) { - popoverRef.current.classList.add('fade') - } - - initPopper(togglerRef.current, popoverRef.current, popperConfig) - popoverRef.current.style.removeProperty('display') - popoverRef.current.classList.add('show') - onShow && onShow() - } + setVisible(true) }, _delay.show) + + return } - return () => { - if (popoverRef.current) { - popoverRef.current.classList.remove('show') - onHide && onHide() - executeAfterTransition(() => { - if (popoverRef.current) { - popoverRef.current.style.display = 'none' - } - - destroyPopper() - setMounted(false) - }, popoverRef.current) - } + if (!mounted && togglerRef.current && popoverRef.current) { + destroyPopper() + } + }, [mounted]) + + useEffect(() => { + if (!_visible && togglerRef.current && popoverRef.current) { + executeAfterTransition(() => { + setMounted(false) + }, popoverRef.current) } }, [_visible]) + const handleShow = () => { + setMounted(true) + if (onShow) { + onShow() + } + } + + const handleHide = () => { + setTimeout(() => { + setVisible(false) + if (onHide) { + onHide() + } + }, _delay.hide) + } + return ( <> {React.cloneElement(children as React.ReactElement, { ...(_visible && { - 'aria-describedby': uID.current, + 'aria-describedby': id, }), ref: togglerRef, ...((trigger === 'click' || trigger.includes('click')) && { - onClick: () => setVisible(!_visible), + onClick: () => (_visible ? handleHide() : handleShow()), }), ...((trigger === 'focus' || trigger.includes('focus')) && { - onFocus: () => setVisible(true), - onBlur: () => setVisible(false), + onFocus: () => handleShow(), + onBlur: () => handleHide(), }), ...((trigger === 'hover' || trigger.includes('hover')) && { - onMouseEnter: () => setVisible(true), - onMouseLeave: () => setVisible(false), + onMouseEnter: () => handleShow(), + onMouseLeave: () => handleHide(), }), })} {mounted && ( -
    -

    React Modal body text goes here.

    -
    -
    - - -
    -
    -
    -
    - -```jsx - - - React Modal title - - -

    React Modal body text goes here.

    -
    - - Close - Save changes - -
    -``` - -### Live demo - -Toggle a working React modal component demo by clicking the button below. It will slide down and fade in from the top of the page. - -export const LiveDemoExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - setVisible(!visible)}>Launch demo modal - setVisible(false)} - aria-labelledby="LiveDemoExampleLabel" - > - - Modal title - - -

    Woohoo, you're reading this text in a modal!

    -
    - - setVisible(false)}> - Close - - Save changes - -
    - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - setVisible(!visible)}>Launch demo modal - setVisible(false)} - aria-labelledby="LiveDemoExampleLabel" - > - - Modal title - - -

    Woohoo, you're reading this text in a modal!

    -
    - - setVisible(false)}> - Close - - Save changes - -
    - -) -``` - -### Static backdrop - -If you set a `backdrop` to `static`, your React modal component will behave as though the backdrop is static, meaning it will not close when clicking outside it. Click the button below to try it. - -export const StaticBackdropExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - setVisible(!visible)}>Launch static backdrop modal - setVisible(false)} - aria-labelledby="StaticBackdropExampleLabel" - > - - Modal title - - - I will not close if you click outside me. Don't even try to press escape key. - - - setVisible(false)}> - Close - - Save changes - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - setVisible(!visible)}>Launch static backdrop modal - setVisible(false)} - aria-labelledby="StaticBackdropExampleLabel" - > - - Modal title - - - I will not close if you click outside me. Don't even try to press escape key. - - - setVisible(false)}> - Close - - Save changes - - - -) -``` - -### Scrolling long content - -When modals become too long for the user's viewport or device, they scroll independent of the page itself. Try the demo below to see what we mean. - -export const ScrollingLongContentExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - setVisible(!visible)}>Launch demo modal - setVisible(false)} - aria-labelledby="ScrollingLongContentExampleLabel" - > - - Modal title - - -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -
    - - setVisible(false)}> - Close - - Save changes - -
    - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - setVisible(!visible)}>Launch demo modal - setVisible(false)} - aria-labelledby="ScrollingLongContentExampleLabel" - > - - Modal title - - -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -
    - - setVisible(false)}> - Close - - Save changes - -
    - -) -``` - -You can also create a scrollable react modal component that allows scroll the modal body by adding `scrollable` prop. - -export const ScrollingLongContentExample2 = () => { - const [visible, setVisible] = useState(false) - return ( - <> - setVisible(!visible)}>Launch demo modal - setVisible(false)} - aria-labelledby="ScrollingLongContentExampleLabel2" - > - - Modal title - - -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -
    - - setVisible(false)}> - Close - - Save changes - -
    - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - setVisible(!visible)}>Launch demo modal - setVisible(false)} - aria-labelledby="ScrollingLongContentExampleLabel2" - > - - Modal title - - -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -
    - - setVisible(false)}> - Close - - Save changes - -
    - -) -``` - -### Vertically centered - -Add `alignment="center` to `` to vertically center the React modal. - -export const VerticallyCenteredExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - setVisible(!visible)}>Vertically centered modal - setVisible(false)} - aria-labelledby="VerticallyCenteredExample" - > - - Modal title - - - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. - - - setVisible(false)}> - Close - - Save changes - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - setVisible(!visible)}>Vertically centered modal - setVisible(false)} - aria-labelledby="VerticallyCenteredExample" - > - - Modal title - - - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, - egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. - - - setVisible(false)}> - Close - - Save changes - - - -) -``` - -export const VerticallyCenteredScrollableExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - setVisible(!visible)}>Vertically centered scrollable modal - setVisible(false)} - aria-labelledby="VerticallyCenteredScrollableExample2" - > - - Modal title - - -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis - lacus vel augue laoreet rutrum faucibus dolor auctor. -

    -
    - - setVisible(false)}> - Close - - Save changes - -
    - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - setVisible(!visible)}>Vertically centered scrollable modal - setVisible(false)} - aria-labelledby="VerticallyCenteredScrollableExample2" - > - - Modal title - - -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -

    - Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel - scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus - auctor fringilla. -

    -

    - Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis - in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. -

    -

    - Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus - vel augue laoreet rutrum faucibus dolor auctor. -

    -
    - - setVisible(false)}> - Close - - Save changes - -
    - -) -``` - -### Tooltips and popovers - -`` and `` can be placed within react modals as needed. When modal components are closed, any tooltips and popovers within are also automatically dismissed. - -export const TooltipsAndPopoversExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - setVisible(!visible)}>Launch demo modal - setVisible(false)} - aria-labelledby="TooltipsAndPopoverExample" - > - - Modal title - - -
    Popover in a modal
    -

    - This - - button - triggers a popover on click. -

    -
    -
    Tooltips in a modal
    -

    - - This link - {' '} - and - - that link - have tooltips on hover. -

    -
    - - setVisible(false)}> - Close - - Save changes - -
    - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - setVisible(!visible)}>Launch demo modal - setVisible(false)} - aria-labelledby="TooltipsAndPopoverExample" - > - - Modal title - - -
    Popover in a modal
    -

    - This - - button - triggers a popover on click. -

    -
    -
    Tooltips in a modal
    -

    - - This link - {' '} - and - - that link - have tooltips on hover. -

    -
    - - setVisible(false)}> - Close - - Save changes - -
    - -) -``` - -### Toggle between modals - -Toggle between multiple modals with some clever placement of the `visible` props. **Please note multiple modals cannot be opened at the same time** — this method simply toggles between two separate modals. - -export const ToggleBetweenModalsExample = () => { - const [visible, setVisible] = useState(false) - const [visible2, setVisible2] = useState(false) - return ( - <> - setVisible(!visible)}>Open first modal - setVisible(false)} - aria-labelledby="ToggleBetweenModalsExample1" - > - - Modal 1 title - - -

    Show a second modal and hide this one with the button below.

    -
    - - { - setVisible(false) - setVisible2(true) - }} - > - Open second modal - - -
    - { - setVisible(true) - setVisible2(false) - }} - aria-labelledby="ToggleBetweenModalsExample2" - > - - Modal 2 title - - -

    Hide this modal and show the first with the button below.

    -
    - - { - setVisible(true) - setVisible2(false) - }} - > - Back to first - - -
    - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -const [visible2, setVisible2] = useState(false) -return ( - <> - setVisible(!visible)}>Open first modal - setVisible(false)} - aria-labelledby="ToggleBetweenModalsExample1" - > - - Modal 1 title - - -

    Show a second modal and hide this one with the button below.

    -
    - - { - setVisible(false) - setVisible2(true) - }} - > - Open second modal - - -
    - { - setVisible(true) - setVisible2(false) - }} - aria-labelledby="ToggleBetweenModalsExample2" - > - - Modal 2 title - - -

    Hide this modal and show the first with the button below.

    -
    - - { - setVisible(true) - setVisible2(false) - }} - > - Back to first - - -
    - -) -``` - -### Change animation - -The variable `$modal-fade-transform` determines the transform state of React Modal component before the modal fade-in animation, whereas the variable `$modal-show-transform` determines the transform state of Modal component after the modal fade-in animation. - -If you want a zoom-in animation, for example, set `$modal-fade-transform: scale(.8)`. - -### Remove animation - -For modals that simply appear rather than fade into view, set `transition` to `false`. - -```jsx -... -``` - -### Accessibility - -Be sure to add `aria-labelledby="..."`, referencing the modal title, to `` Additionally, you may give a description of your modal dialog with `aria-describedby` on ``. Note that you don’t need to add `role="dialog`, `aria-hidden="true"`, and `aria-modal="true"` since we already add it. - -## Optional sizes - -Modals have three optional sizes, available via modifier classes to be placed on a ``. These sizes kick in at certain breakpoints to avoid horizontal scrollbars on narrower viewports. - -| Size | Property size | Modal max-width | -| ----------- | ------------- | --------------- | -| Small | `'sm'` | `300px` | -| Default | None | `500px` | -| Large | `'lg'` | `800px` | -| Extra large | `'xl'` | `1140px` | - -export const OptionalSizesExample = () => { - const [visibleXL, setVisibleXL] = useState(false) - const [visibleLg, setVisibleLg] = useState(false) - const [visibleSm, setVisibleSm] = useState(false) - return ( - <> - setVisibleXL(!visibleXL)}>Extra large modal - setVisibleLg(!visibleLg)}>Large modal - setVisibleSm(!visibleSm)}>Small modal - setVisibleXL(false)} - aria-labelledby="OptionalSizesExample1" - > - - Extra large modal - - ... - - setVisibleLg(false)} - aria-labelledby="OptionalSizesExample2" - > - - Large modal - - ... - - setVisibleSm(false)} - aria-labelledby="OptionalSizesExample3" - > - - Small modal - - ... - - - ) -} - - - - - -```jsx -const [visibleXL, setVisibleXL] = useState(false) -const [visibleLg, setVisibleLg] = useState(false) -const [visibleSm, setVisibleSm] = useState(false) -return ( - <> - setVisibleXL(!visibleXL)}>Extra large modal - setVisibleLg(!visibleLg)}>Large modal - setVisibleSm(!visibleSm)}>Small modal - setVisibleXL(false)} - aria-labelledby="OptionalSizesExample1" - > - - Extra large modal - - ... - - setVisibleLg(false)} - aria-labelledby="OptionalSizesExample2" - > - - Large modal - - ... - - setVisibleSm(false)} - aria-labelledby="OptionalSizesExample3" - > - - Small modal - - ... - - -) -``` - -## Fullscreen Modal - -Another override is the option to pop up a React modal component that covers the user viewport, available via property `fullscrean`. - -| Fullscrean | Availability | -| ---------- | -------------- | -| `true` | Always | -| `'sm'` | Below `576px` | -| `'md'` | Below `768px` | -| `'lg'` | Below `992px` | -| `'xl'` | Below `1200px` | -| `'xxl'` | Below `1400px` | - -export const FullscreenExample = () => { - const [visible, setVisible] = useState(false) - const [visibleSm, setVisibleSm] = useState(false) - const [visibleMd, setVisibleMd] = useState(false) - const [visibleLg, setVisibleLg] = useState(false) - const [visibleXL, setVisibleXL] = useState(false) - const [visibleXXL, setVisibleXXL] = useState(false) - return ( - <> - setVisible(!visible)}>Full screen - setVisibleSm(!visibleSm)}>Full screen below sm - setVisibleMd(!visibleMd)}>Full screen below md - setVisibleLg(!visibleLg)}>Full screen below lg - setVisibleXL(!visibleXL)}>Full screen below xl - setVisibleXXL(!visibleXXL)}>Full screen below xxl - setVisible(false)} - aria-labelledby="FullscreenExample1" - > - - Full screen - - ... - - setVisibleSm(false)} - aria-labelledby="FullscreenExample2" - > - - Full screen below sm - - ... - - setVisibleMd(false)} - aria-labelledby="FullscreenExample3" - > - - Full screen below md - - ... - - setVisibleLg(false)} - aria-labelledby="FullscreenExample4" - > - - Full screen below lg - - ... - - setVisibleXL(false)} - aria-labelledby="FullscreenExample5" - > - - Full screen below xl - - ... - - setVisibleXXL(false)} - aria-labelledby="FullscreenExample6" - > - - Full screen below xxl - - ... - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -const [visibleSm, setVisibleSm] = useState(false) -const [visibleMd, setVisibleMd] = useState(false) -const [visibleLg, setVisibleLg] = useState(false) -const [visibleXL, setVisibleXL] = useState(false) -const [visibleXXL, setVisibleXXL] = useState(false) -return ( - <> - setVisible(!visible)}>Full screen - setVisibleSm(!visibleSm)}>Full screen below sm - setVisibleMd(!visibleMd)}>Full screen below md - setVisibleLg(!visibleLg)}>Full screen below lg - setVisibleXL(!visibleXL)}>Full screen below xl - setVisibleXXL(!visibleXXL)}>Full screen below xxl - setVisible(false)} - aria-labelledby="FullscreenExample1" - > - - Full screen - - ... - - setVisibleSm(false)} - aria-labelledby="FullscreenExample2" - > - - Full screen below sm - - ... - - setVisibleMd(false)} - aria-labelledby="FullscreenExample3" - > - - Full screen below md - - ... - - setVisibleLg(false)} - aria-labelledby="FullscreenExample4" - > - - Full screen below lg - - ... - - setVisibleXL(false)} - aria-labelledby="FullscreenExample5" - > - - Full screen below xl - - ... - - setVisibleXXL(false)} - aria-labelledby="FullscreenExample6" - > - - Full screen below xxl - - ... - - -) -``` - -## Customizing - -### CSS variables - -React modals use local CSS variables on `.modal` and `.modal-backdrop` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too. - - - - - -#### How to use CSS variables - -```jsx -const vars = { - '--my-css-var': 10, - '--my-another-css-var': 'red', -} -return ... -``` - -### SASS variables - - - -### SASS loops - -[Responsive fullscreen modals](#fullscreen-modal) are generated via the `$breakpoints` map and a loop in `scss/_modal.scss`. - - - -## API - -### CModal - -`markdown:CModal.api.mdx` - -### CModalBody - -`markdown:CModalBody.api.mdx` - -### CModalFooter - -`markdown:CModalFooter.api.mdx` - -### CModalHeader - -`markdown:CModalHeader.api.mdx` - -### CModalTitle - -`markdown:CModalTitle.api.mdx` diff --git a/packages/docs/content/components/modal/api.mdx b/packages/docs/content/components/modal/api.mdx new file mode 100644 index 00000000..294226af --- /dev/null +++ b/packages/docs/content/components/modal/api.mdx @@ -0,0 +1,32 @@ +--- +title: React Modal Component API +name: Modal API +description: Explore the API reference for the React Modal component and discover how to effectively utilize its props for customization. +route: /components/modal/ +--- + +import CModalAPI from '../../api/CModal.api.mdx' +import CModalBodyAPI from '../../api/CModalBody.api.mdx' +import CModalFooterAPI from '../../api/CModalFooter.api.mdx' +import CModalHeaderAPI from '../../api/CModalHeader.api.mdx' +import CModalTitleAPI from '../../api/CModalTitle.api.mdx' + +## CModal + + + +## CModalBody + + + +## CModalFooter + + + +## CModalHeader + + + +## CModalTitle + + diff --git a/packages/docs/content/components/modal/examples/ModalFullscreenExample.tsx b/packages/docs/content/components/modal/examples/ModalFullscreenExample.tsx new file mode 100644 index 00000000..267c0797 --- /dev/null +++ b/packages/docs/content/components/modal/examples/ModalFullscreenExample.tsx @@ -0,0 +1,99 @@ +import React, { useState } from 'react' +import { CButton, CModal, CModalBody, CModalHeader, CModalTitle } from '@coreui/react' + +export const ModalFullscreenExample = () => { + const [visible, setVisible] = useState(false) + const [visibleSm, setVisibleSm] = useState(false) + const [visibleMd, setVisibleMd] = useState(false) + const [visibleLg, setVisibleLg] = useState(false) + const [visibleXL, setVisibleXL] = useState(false) + const [visibleXXL, setVisibleXXL] = useState(false) + return ( + <> + setVisible(!visible)}> + Full screen + + setVisibleSm(!visibleSm)}> + Full screen below sm + + setVisibleMd(!visibleMd)}> + Full screen below md + + setVisibleLg(!visibleLg)}> + Full screen below lg + + setVisibleXL(!visibleXL)}> + Full screen below xl + + setVisibleXXL(!visibleXXL)}> + Full screen below xxl + + setVisible(false)} + aria-labelledby="FullscreenExample1" + > + + Full screen + + ... + + setVisibleSm(false)} + aria-labelledby="FullscreenExample2" + > + + Full screen below sm + + ... + + setVisibleMd(false)} + aria-labelledby="FullscreenExample3" + > + + Full screen below md + + ... + + setVisibleLg(false)} + aria-labelledby="FullscreenExample4" + > + + Full screen below lg + + ... + + setVisibleXL(false)} + aria-labelledby="FullscreenExample5" + > + + Full screen below xl + + ... + + setVisibleXXL(false)} + aria-labelledby="FullscreenExample6" + > + + Full screen below xxl + + ... + + + ) +} diff --git a/packages/docs/content/components/modal/examples/ModalLiveDemoExample.tsx b/packages/docs/content/components/modal/examples/ModalLiveDemoExample.tsx new file mode 100644 index 00000000..3bd28d2f --- /dev/null +++ b/packages/docs/content/components/modal/examples/ModalLiveDemoExample.tsx @@ -0,0 +1,29 @@ +import React, { useState } from 'react' +import { CButton, CModal, CModalBody, CModalFooter, CModalHeader, CModalTitle } from '@coreui/react' + +export const ModalLiveDemoExample = () => { + const [visible, setVisible] = useState(false) + return ( + <> + setVisible(!visible)}> + Launch demo modal + + setVisible(false)} + aria-labelledby="LiveDemoExampleLabel" + > + + Modal title + + Woohoo, you're reading this text in a modal! + + setVisible(false)}> + Close + + Save changes + + + + ) +} diff --git a/packages/docs/content/components/modal/examples/ModalOptionalSizesExample.tsx b/packages/docs/content/components/modal/examples/ModalOptionalSizesExample.tsx new file mode 100644 index 00000000..a082c37a --- /dev/null +++ b/packages/docs/content/components/modal/examples/ModalOptionalSizesExample.tsx @@ -0,0 +1,54 @@ +import React, { useState } from 'react' +import { CButton, CModal, CModalBody, CModalHeader, CModalTitle } from '@coreui/react' + +export const ModalOptionalSizesExample = () => { + const [visibleXL, setVisibleXL] = useState(false) + const [visibleLg, setVisibleLg] = useState(false) + const [visibleSm, setVisibleSm] = useState(false) + return ( + <> + setVisibleXL(!visibleXL)}> + Extra large modal + + setVisibleLg(!visibleLg)}> + Large modal + + setVisibleSm(!visibleSm)}> + Small modal + + setVisibleXL(false)} + aria-labelledby="OptionalSizesExample1" + > + + Extra large modal + + ... + + setVisibleLg(false)} + aria-labelledby="OptionalSizesExample2" + > + + Large modal + + ... + + setVisibleSm(false)} + aria-labelledby="OptionalSizesExample3" + > + + Small modal + + ... + + + ) +} diff --git a/packages/docs/content/components/modal/examples/ModalScrollingLongContent2Example.tsx b/packages/docs/content/components/modal/examples/ModalScrollingLongContent2Example.tsx new file mode 100644 index 00000000..0e4d9a95 --- /dev/null +++ b/packages/docs/content/components/modal/examples/ModalScrollingLongContent2Example.tsx @@ -0,0 +1,53 @@ +import React, { useState } from 'react' +import { CButton, CModal, CModalBody, CModalFooter, CModalHeader, CModalTitle } from '@coreui/react' + +export const ModalScrollingLongContent2Example = () => { + const [visible, setVisible] = useState(false) + return ( + <> + setVisible(!visible)}> + Vertically centered scrollable modal + + setVisible(false)} + aria-labelledby="VerticallyCenteredScrollableExample2" + > + + Modal title + + +

    + Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. +

    +

    + Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis + lacus vel augue laoreet rutrum faucibus dolor auctor. +

    +

    + Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel + scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus + auctor fringilla. +

    +

    + Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. +

    +

    + Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis + lacus vel augue laoreet rutrum faucibus dolor auctor. +

    +
    + + setVisible(false)}> + Close + + Save changes + +
    + + ) +} diff --git a/packages/docs/content/components/modal/examples/ModalScrollingLongContentExample.tsx b/packages/docs/content/components/modal/examples/ModalScrollingLongContentExample.tsx new file mode 100644 index 00000000..33ab2119 --- /dev/null +++ b/packages/docs/content/components/modal/examples/ModalScrollingLongContentExample.tsx @@ -0,0 +1,108 @@ +import React, { useState } from 'react' +import { CButton, CModal, CModalBody, CModalFooter, CModalHeader, CModalTitle } from '@coreui/react' + +export const ModalScrollingLongContentExample = () => { + const [visible, setVisible] = useState(false) + return ( + <> + setVisible(!visible)}> + Launch demo modal + + setVisible(false)} + aria-labelledby="ScrollingLongContentExampleLabel" + > + + Modal title + + +

    + Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. +

    +

    + Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis + lacus vel augue laoreet rutrum faucibus dolor auctor. +

    +

    + Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel + scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus + auctor fringilla. +

    +

    + Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. +

    +

    + Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis + lacus vel augue laoreet rutrum faucibus dolor auctor. +

    +

    + Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel + scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus + auctor fringilla. +

    +

    + Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. +

    +

    + Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis + lacus vel augue laoreet rutrum faucibus dolor auctor. +

    +

    + Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel + scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus + auctor fringilla. +

    +

    + Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. +

    +

    + Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis + lacus vel augue laoreet rutrum faucibus dolor auctor. +

    +

    + Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel + scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus + auctor fringilla. +

    +

    + Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. +

    +

    + Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis + lacus vel augue laoreet rutrum faucibus dolor auctor. +

    +

    + Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel + scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus + auctor fringilla. +

    +

    + Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. +

    +

    + Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis + lacus vel augue laoreet rutrum faucibus dolor auctor. +

    +

    + Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel + scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus + auctor fringilla. +

    +
    + + setVisible(false)}> + Close + + Save changes + +
    + + ) +} diff --git a/packages/docs/content/components/modal/examples/ModalStaticBackdropExample.tsx b/packages/docs/content/components/modal/examples/ModalStaticBackdropExample.tsx new file mode 100644 index 00000000..859b1d89 --- /dev/null +++ b/packages/docs/content/components/modal/examples/ModalStaticBackdropExample.tsx @@ -0,0 +1,32 @@ +import React, { useState } from 'react' +import { CButton, CModal, CModalBody, CModalFooter, CModalHeader, CModalTitle } from '@coreui/react' + +export const ModalStaticBackdropExample = () => { + const [visible, setVisible] = useState(false) + return ( + <> + setVisible(!visible)}> + Launch static backdrop modal + + setVisible(false)} + aria-labelledby="StaticBackdropExampleLabel" + > + + Modal title + + + I will not close if you click outside me. Don't even try to press escape key. + + + setVisible(false)}> + Close + + Save changes + + + + ) +} diff --git a/packages/docs/content/components/modal/examples/ModalToggleBetweenModalsExample.tsx b/packages/docs/content/components/modal/examples/ModalToggleBetweenModalsExample.tsx new file mode 100644 index 00000000..ba6af0ff --- /dev/null +++ b/packages/docs/content/components/modal/examples/ModalToggleBetweenModalsExample.tsx @@ -0,0 +1,63 @@ +import React, { useState } from 'react' +import { CButton, CModal, CModalBody, CModalFooter, CModalHeader, CModalTitle } from '@coreui/react' + +export const ModalToggleBetweenModalsExample = () => { + const [visible, setVisible] = useState(false) + const [visible2, setVisible2] = useState(false) + return ( + <> + setVisible(!visible)}> + Open first modal + + setVisible(false)} + aria-labelledby="ToggleBetweenModalsExample1" + > + + Modal 1 title + + +

    Show a second modal and hide this one with the button below.

    +
    + + { + setVisible(false) + setVisible2(true) + }} + > + Open second modal + + +
    + { + setVisible(true) + setVisible2(false) + }} + aria-labelledby="ToggleBetweenModalsExample2" + > + + Modal 2 title + + +

    Hide this modal and show the first with the button below.

    +
    + + { + setVisible(true) + setVisible2(false) + }} + > + Back to first + + +
    + + ) +} diff --git a/packages/docs/content/components/modal/examples/ModalTooltipsAndPopoversExample.tsx b/packages/docs/content/components/modal/examples/ModalTooltipsAndPopoversExample.tsx new file mode 100644 index 00000000..46d73846 --- /dev/null +++ b/packages/docs/content/components/modal/examples/ModalTooltipsAndPopoversExample.tsx @@ -0,0 +1,61 @@ +import React, { useState } from 'react' +import { + CButton, + CModal, + CModalBody, + CModalFooter, + CModalHeader, + CModalTitle, + CLink, + CPopover, + CTooltip, +} from '@coreui/react' + +export const ModalTooltipsAndPopoversExample = () => { + const [visible, setVisible] = useState(false) + return ( + <> + setVisible(!visible)}> + Launch demo modal + + setVisible(false)} + aria-labelledby="TooltipsAndPopoverExample" + > + + Modal title + + +
    Popover in a modal
    +

    + This + + button + {' '} + triggers a popover on click. +

    +
    +
    Tooltips in a modal
    +

    + + This link + {' '} + and + + that link + {' '} + have tooltips on hover. +

    +
    + + setVisible(false)}> + Close + + Save changes + +
    + + ) +} diff --git a/packages/docs/content/components/modal/examples/ModalVerticallyCenteredExample.tsx b/packages/docs/content/components/modal/examples/ModalVerticallyCenteredExample.tsx new file mode 100644 index 00000000..f2f43f4e --- /dev/null +++ b/packages/docs/content/components/modal/examples/ModalVerticallyCenteredExample.tsx @@ -0,0 +1,33 @@ +import React, { useState } from 'react' +import { CButton, CModal, CModalBody, CModalFooter, CModalHeader, CModalTitle } from '@coreui/react' + +export const ModalVerticallyCenteredExample = () => { + const [visible, setVisible] = useState(false) + return ( + <> + setVisible(!visible)}> + Vertically centered modal + + setVisible(false)} + aria-labelledby="VerticallyCenteredExample" + > + + Modal title + + + Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. + + + setVisible(false)}> + Close + + Save changes + + + + ) +} diff --git a/packages/docs/content/components/modal/examples/ModalVerticallyCenteredScrollableExample.tsx b/packages/docs/content/components/modal/examples/ModalVerticallyCenteredScrollableExample.tsx new file mode 100644 index 00000000..0cc92aea --- /dev/null +++ b/packages/docs/content/components/modal/examples/ModalVerticallyCenteredScrollableExample.tsx @@ -0,0 +1,53 @@ +import React, { useState } from 'react' +import { CButton, CModal, CModalBody, CModalFooter, CModalHeader, CModalTitle } from '@coreui/react' + +export const ModalVerticallyCenteredScrollableExample = () => { + const [visible, setVisible] = useState(false) + return ( + <> + setVisible(!visible)}> + Vertically centered scrollable modal + + setVisible(false)} + aria-labelledby="VerticallyCenteredScrollableExample2" + > + + Modal title + + +

    + Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. +

    +

    + Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis + lacus vel augue laoreet rutrum faucibus dolor auctor. +

    +

    + Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel + scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus + auctor fringilla. +

    +

    + Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis + in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. +

    +

    + Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis + lacus vel augue laoreet rutrum faucibus dolor auctor. +

    +
    + + setVisible(false)}> + Close + + Save changes + +
    + + ) +} diff --git a/packages/docs/content/components/modal/index.mdx b/packages/docs/content/components/modal/index.mdx new file mode 100644 index 00000000..3ff5a3b0 --- /dev/null +++ b/packages/docs/content/components/modal/index.mdx @@ -0,0 +1,146 @@ +--- +title: React Modal Component +name: Modal +description: React Modal component offers a lightweight, multi-purpose popup to add dialogs to yours. Learn how to customize CoreUI React modal components easily. Multiple examples and tutorial. +route: /components/modal/ +other_frameworks: modal +--- + +## How to use React Modal Component? + +### Static modal component example + +Below is a static react modal component example (meaning its `position` and `display` have been overridden). Included are the modal header, modal body (required for `padding`), and modal footer (optional). We ask that you include react modal headers with dismiss actions whenever possible, or provide another explicit dismiss action. + + +
    +
    +
    +
    +
    React Modal title
    + +
    +
    +

    React Modal body text goes here.

    +
    +
    + + +
    +
    +
    +
    +
    +```jsx + + + React Modal title + + +

    React Modal body text goes here.

    +
    + + Close + Save changes + +
    +``` + +### Live demo + +Toggle a working React modal component demo by clicking the button below. It will slide down and fade in from the top of the page. + + + +### Static backdrop + +If you set a `backdrop` to `static`, your React modal component will behave as though the backdrop is static, meaning it will not close when clicking outside it. Click the button below to try it. + + + +### Scrolling long content + +When modals become too long for the user's viewport or device, they scroll independent of the page itself. Try the demo below to see what we mean. + + + +You can also create a scrollable react modal component that allows scroll the modal body by adding `scrollable` prop. + + + +### Vertically centered + +Add `alignment="center` to `` to vertically center the React modal. + + + + + +### Tooltips and popovers + +`` and `` can be placed within react modals as needed. When modal components are closed, any tooltips and popovers within are also automatically dismissed. + + + +### Toggle between modals + +Toggle between multiple modals with some clever placement of the `visible` props. **Please note multiple modals cannot be opened at the same time** — this method simply toggles between two separate modals. + + + +### Change animation + +The variable `$modal-fade-transform` determines the transform state of React Modal component before the modal fade-in animation, whereas the variable `$modal-show-transform` determines the transform state of Modal component after the modal fade-in animation. + +If you want a zoom-in animation, for example, set `$modal-fade-transform: scale(.8)`. + +### Remove animation + +For modals that simply appear rather than fade into view, set `transition` to `false`. + +```jsx +... +``` + +### Accessibility + +Be sure to add `aria-labelledby="..."`, referencing the modal title, to `` Additionally, you may give a description of your modal dialog with `aria-describedby` on ``. Note that you don’t need to add `role="dialog`, `aria-hidden="true"`, and `aria-modal="true"` since we already add it. + +## Optional sizes + +Modals have three optional sizes, available via modifier classes to be placed on a ``. These sizes kick in at certain breakpoints to avoid horizontal scrollbars on narrower viewports. + + +| Size | Property size | Modal max-width | +| ----------- | ------------- | --------------- | +| Small | `'sm'` | `300px` | +| Default | None | `500px` | +| Large | `'lg'` | `800px` | +| Extra large | `'xl'` | `1140px` | + + + +## Fullscreen Modal + +Another override is the option to pop up a React modal component that covers the user viewport, available via property `fullscrean`. + +| Fullscrean | Availability | +| ---------- | -------------- | +| `true` | Always | +| `'sm'` | Below `576px` | +| `'md'` | Below `768px` | +| `'lg'` | Below `992px` | +| `'xl'` | Below `1200px` | +| `'xxl'` | Below `1400px` | + + + +## API + +Check out the documentation below for a comprehensive guide to all the props you can use with the components mentioned here. + +- [<CModal />](./api/#cmodal) +- [<CModalBody />](./api/#cmodalbody) +- [<CModalFooter />](./api/#cmodalfooter) +- [<CModalHeader />](./api/#cmodalheader) +- [<CModalTitle />](./api/#cmodaltitle) diff --git a/packages/docs/content/components/modal/styling.mdx b/packages/docs/content/components/modal/styling.mdx new file mode 100644 index 00000000..41200c16 --- /dev/null +++ b/packages/docs/content/components/modal/styling.mdx @@ -0,0 +1,35 @@ +--- +title: React Modal Component Styling +name: Modal Styling +description: Learn how to customize the React Modal component with CSS classes, variables, and SASS for flexible styling and seamless integration into your design. +route: /components/modal/ +--- + +### CSS variables + +React Modal supports CSS variables for easy customization. These variables are set via SASS but allow direct overrides in your stylesheets or inline styles. + + + + + +#### How to use CSS variables + +```jsx +const customVars = { + '--cui-modal-color': '#555', + '--cui-modal-bg': '#efefef', +} + +return {/* Modal content */} +``` + +### SASS variables + + + +### SASS loops + +[Responsive fullscreen modals](#fullscreen-modal) are generated via the `$breakpoints` map and a loop in `scss/_modal.scss`. + + diff --git a/packages/docs/content/components/navbar.mdx b/packages/docs/content/components/navbar.mdx deleted file mode 100644 index 3cf2d2cf..00000000 --- a/packages/docs/content/components/navbar.mdx +++ /dev/null @@ -1,1475 +0,0 @@ ---- -title: React Navbar Component -name: Navbar -description: Documentation and examples for the React navbar powerful, responsive navigation header component. Includes support for branding, links, dropdowns, and more. -menu: Components -route: /components/navbar -other_frameworks: navbar ---- - -import { useState } from 'react' -import { - CButton, - CContainer, - CCloseButton, - CCollapse, - CDropdown, - CDropdownDivider, - CDropdownHeader, - CDropdownItem, - CDropdownItemPlain, - CDropdownMenu, - CDropdownToggle, - CForm, - CFormInput, - CInputGroup, - CInputGroupText, - CNav, - CNavItem, - CNavLink, - CNavbar, - CNavbarBrand, - CNavbarNav, - CNavbarText, - CNavbarToggler, - COffcanvas, - COffcanvasBody, - COffcanvasHeader, - COffcanvasTitle, -} from '@coreui/react/src/index' - -import CoreUISignetImg from './../assets/images/brand/coreui-signet.svg' - -## Supported content - -`` come with built-in support for a handful of sub-components. Choose from the following as needed: - -- `` for your company, product, or project name. -- `` for a full-height and lightweight navigation (including support for dropdowns). -- `` for use with our collapse plugin and other [navigation toggling](#responsive-behaviors) behaviors. -- Flex and spacing utilities for any form controls and actions. -- `` for adding vertically centered strings of text. -- `` for grouping and hiding navbar contents by a parent breakpoint. - -Here's an example of all the sub-components included in a responsive light-themed navbar that automatically collapses at the `lg` (large) breakpoint. - -## Basic usage - -export const BasicUsageExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - - - Navbar - setVisible(!visible)} /> - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - - - Navbar - setVisible(!visible)} /> - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - - -) -``` - -### Brand - -The `` can be applied to most elements, but an anchor works best, as some elements might require utility classes or custom styles. - -```jsx preview - - - Navbar - - -
    - - - Navbar - - -``` - -Adding images to the `` will likely always require custom styles or utilities to properly size. Here are some examples to demonstrate. - -```jsx preview - - - - - - - -``` - -```jsx preview - - - - CoreUI - - - -``` - -### Nav - -`` navigation is based on ``. **Navigation in navbars will also grow to occupy as much horizontal space as possible** to keep your navbar contents securely aligned. - -export const NavExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Features - - - Pricing - - - - Disabled - - - - - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Features - - - Pricing - - - - Disabled - - - - - - - -) -``` - -And because we use classes for our navs, you can avoid the list-based approach entirely if you like. - -export const NavExample2 = () => { - const [visible, setVisible] = useState(false) - return ( - <> - - - Navbar - setVisible(!visible)} - /> - - - - Home - - Features - Pricing - - Disabled - - - - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - - - Navbar - setVisible(!visible)} - /> - - - - Home - - Features - Pricing - - Disabled - - - - - - -) -``` - -You can also use dropdowns in your navbar. Please note that `` component requires `variant="nav-item"`. - -export const NavDropdownExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Features - - - Pricing - - - Dropdown link - - Action - Another action - - Something else here - - - - - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Features - - - Pricing - - - Dropdown link - - Action - Another action - - Something else here - - - - - - - -) -``` - -### Forms - -Place various form controls and components within a navbar: - -```jsx preview - - - - - - Search - - - - -``` - -Immediate child elements of `` use flex layout and will default to `justify-content: space-between`. Use additional [flex utilities](https://coreui.io/docs/utilities/flex/) as needed to adjust this behavior. - -```jsx preview - - - Navbar - - - - Search - - - - -``` - -Input groups work, too. If your navbar is an entire form, or mostly a form, you can use the `` element as the container and save some HTML. - -```jsx preview - - - - @ - - - - -``` - -Various buttons are supported as part of these navbar forms, too. This is also a great reminder that vertical alignment utilities can be used to align different sized elements. - -```jsx preview - - - - Main button - - - Smaller button - - - -``` - -### Text - -Navbars may contain bits of text with the help of ``. This class adjusts vertical alignment and horizontal spacing for strings of text. - -```jsx preview - - - Navbar text with an inline element - - -``` - -## Color schemes - -Theming the navbar has never been easier thanks to the combination of theming classes and `background-color` utilities. Set `colorScheme="light"` for use with light background colors, or `colorScheme="dark"` for dark background colors. Then, customize with `.bg-*` utilities. - -export const ColorSchemesExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - -
    - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - -
    - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - - -) -``` - -## Containers - -Although it's not required, you can wrap a `` in a `` to center it on a page–though note that an inner container is still required. Or you can add a container inside the `` to only center the contents of a [fixed or static top navbar](#placement). - -```jsx preview - - - - Navbar - - - -``` - -Use any of the responsive containers to change how wide the content in your navbar is presented. - -```jsx preview - - - Navbar - - -``` - -## Placement - -Use our `placement` properly to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, or stickied to the top (scrolls with the page until it reaches the top, then stays there). Fixed navbars use `position: fixed`, meaning they're pulled from the normal flow of the DOM and may require custom CSS (e.g., `padding-top` on the ``) to prevent overlap with other elements. - -Also note that **`.sticky-top` uses `position: sticky`, which [isn't fully supported in every browser](https://caniuse.com/css-sticky)**. - -```jsx preview - - - Default - - -``` - -```jsx preview - - - Fixed top - - -``` - -```jsx preview - - - Fixed bottom - - -``` - -```jsx preview - - - Sticky top - - -``` - -## Responsive behaviors - -Navbars can use ``, ``, and `expand="{sm|md|lg|xl|xxl}"` property to determine when their content collapses behind a button. In combination with other utilities, you can easily choose when to show or hide particular elements. - -For navbars that never collapse, add the `expand` boolean property on the ``. For navbars that always collapse, don't add any property. - -### Toggler - -Navbar togglers are left-aligned by default, but should they follow a sibling element like a ``, they'll automatically be aligned to the far right. Reversing your markup will reverse the placement of the toggler. Below are examples of different toggle styles. - -With no `` shown at the smallest breakpoint: - -export const ResponsiveBehaviorsExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - - - setVisible(!visible)} - /> - - Hidden brand - - - - Home - - - - Link - - - - Disabled - - - - - - - Search - - - - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - - - setVisible(!visible)} - /> - - Hidden brand - - - - Home - - - - Link - - - - Disabled - - - - - - - Search - - - - - - -) -``` - -With a brand name shown on the left and toggler on the right: - -export const ResponsiveBehaviorsExample2 = () => { - const [visible, setVisible] = useState(false) - return ( - <> - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Link - - - - Disabled - - - - - - - Search - - - - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - - - Navbar - setVisible(!visible)} - /> - - - - - Home - - - - Link - - - - Disabled - - - - - - - Search - - - - - - -) -``` - -With a toggler on the left and brand name on the right: - -export const ResponsiveBehaviorsExample3 = () => { - const [visible, setVisible] = useState(false) - return ( - <> - - - setVisible(!visible)} - /> - Navbar - - - - - Home - - - - Link - - - - Disabled - - - - - - - Search - - - - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - - - setVisible(!visible)} - /> - Navbar - - - - - Home - - - - Link - - - - Disabled - - - - - - - Search - - - - - - -) -``` - -### External content - -Sometimes you want to use the collapse plugin to trigger a container element for content that structurally sits outside of the ``. - -export const ExternalContentExample = () => { - const [visible, setVisible] = useState(false) - return ( - <> - -
    -
    Collapsed content
    - Toggleable via the navbar brand. -
    -
    - - - setVisible(!visible)} - /> - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - <> - -
    -
    Collapsed content
    - Toggleable via the navbar brand. -
    -
    - - - setVisible(!visible)} - /> - - - -) -``` - -### Offcanvas - -Transform your expanding and collapsing navbar into an offcanvas drawer with the offcanvas plugin. We extend both the offcanvas default styles and use our `expand="*"` prop to create a dynamic and flexible navigation sidebar. - -In the example below, to create an offcanvas navbar that is always collapsed across all breakpoints, omit the `expand="*"` prop entirely. - -export const OffcanvasExample = () => { - const [visible, setVisible] = useState(false) - return ( - - - Offcanvas navbar - setVisible(!visible)} - /> - setVisible(false)}> - - Offcanvas - setVisible(false)} /> - - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - - - Offcanvas navbar - setVisible(!visible)} - /> - setVisible(false)}> - - Offcanvas - setVisible(false)} /> - - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - - -) -``` - -To create an offcanvas navbar that expands into a normal navbar at a specific breakpoint like `xxl`, use `expand="xxl"` property. - -export const OffcanvasExample2 = () => { - const [visible, setVisible] = useState(false) - return ( - - - Offcanvas navbar - setVisible(!visible)} - /> - setVisible(false)}> - - Offcanvas - setVisible(false)} /> - - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - - - ) -} - - - - - -```jsx -const [visible, setVisible] = useState(false) -return ( - - Offcanvas navbar - - setVisible(!visible)} - /> - setVisible(false)}> - - Offcanvas - setVisible(false)} /> - - - - - - Home - - - - Link - - - Dropdown button - - Action - Another action - - Something else here - - - - - Disabled - - - - - - - Search - - - - - - -) -``` - -## Customizing - -### CSS variables - -React navbars use local CSS variables on `.navbar` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too. - - - -Some additional CSS variables are also present on `.navbar-nav`: - - - -Customization through CSS variables can be seen on the `.navbar-dark` class where we override specific values without adding duplicate CSS selectors. - - - -#### How to use CSS variables - -```jsx -const vars = { - '--my-css-var': 10, - '--my-another-css-var': "red" -} -return ... -``` - -### SASS variables - -Variables for all navbars: - - - -Variables for the [dark navbar](#color-schemes): - - - -### SASS loops - -[Responsive navbar expand/collapse classes](#responsive-behaviors) (e.g., `.navbar-expand-lg`) are combined with the `$breakpoints` map and generated through a loop in `scss/_navbar.scss`. - - - -## API - -### CNavbar - -`markdown:CNavbar.api.mdx` - -### CNavbarBrand - -`markdown:CNavbarBrand.api.mdx` - -### CNavbarNav - -`markdown:CNavbarNav.api.mdx` - -### CNavbarText - -`markdown:CNavbarText.api.mdx` - -### CNavbarToggler - -`markdown:CNavbarToggler.api.mdx` diff --git a/packages/docs/content/components/navbar/api.mdx b/packages/docs/content/components/navbar/api.mdx new file mode 100644 index 00000000..5170c089 --- /dev/null +++ b/packages/docs/content/components/navbar/api.mdx @@ -0,0 +1,32 @@ +--- +title: React Navbar Component API +name: Navbar API +description: Explore the API reference for the React Navbar component and discover how to effectively utilize its props for customization. +route: /components/navbar/ +--- + +import CNavbarAPI from '../../api/CNavbar.api.mdx' +import CNavbarBrandAPI from '../../api/CNavbarBrand.api.mdx' +import CNavbarNavAPI from '../../api/CNavbarNav.api.mdx' +import CNavbarTextAPI from '../../api/CNavbarText.api.mdx' +import CNavbarTogglerAPI from '../../api/CNavbarToggler.api.mdx' + +## CNavbar + + + +## CNavbarBrand + + + +## CNavbarNav + + + +## CNavbarText + + + +## CNavbarToggler + + diff --git a/packages/docs/content/components/navbar/examples/NavbarBrand2Example.tsx b/packages/docs/content/components/navbar/examples/NavbarBrand2Example.tsx new file mode 100644 index 00000000..dc5a13de --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarBrand2Example.tsx @@ -0,0 +1,16 @@ +import React from 'react' +import { CContainer, CNavbar, CNavbarBrand } from '@coreui/react' + +import CoreUISignetImg from '@assets/images/brand/coreui-signet.svg' + +export const NavbarBrand2Example = () => { + return ( + + + + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarBrand3Example.tsx b/packages/docs/content/components/navbar/examples/NavbarBrand3Example.tsx new file mode 100644 index 00000000..70c6b9fa --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarBrand3Example.tsx @@ -0,0 +1,23 @@ +import React from 'react' +import { CContainer, CNavbar, CNavbarBrand } from '@coreui/react' + +import CoreUISignetImg from '@assets/images/brand/coreui-signet.svg' + +export const NavbarBrand3Example = () => { + return ( + + + + {' '} + CoreUI + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarBrandExample.tsx b/packages/docs/content/components/navbar/examples/NavbarBrandExample.tsx new file mode 100644 index 00000000..a351cf18 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarBrandExample.tsx @@ -0,0 +1,22 @@ +import React from 'react' +import { CContainer, CNavbar, CNavbarBrand } from '@coreui/react' + +export const NavbarBrandExample = () => { + return ( + <> + {/* As a link */} + + + Navbar + + + + {/* As a heading */} + + + Navbar + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarColorSchemesExample.tsx b/packages/docs/content/components/navbar/examples/NavbarColorSchemesExample.tsx new file mode 100644 index 00000000..6c53aca8 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarColorSchemesExample.tsx @@ -0,0 +1,155 @@ +import React, { useState } from 'react' +import { + CButton, + CCollapse, + CContainer, + CDropdown, + CDropdownDivider, + CDropdownItem, + CDropdownMenu, + CDropdownToggle, + CForm, + CFormInput, + CNavbar, + CNavbarBrand, + CNavbarNav, + CNavbarToggler, + CNavItem, + CNavLink, +} from '@coreui/react' + +export const NavbarColorSchemesExample = () => { + const [visible, setVisible] = useState(false) + return ( + <> + + + Navbar + setVisible(!visible)} + /> + + + + + Home + + + + Link + + + Dropdown button + + Action + Another action + + Something else here + + + + + Disabled + + + + + + + Search + + + + + +
    + + + Navbar + setVisible(!visible)} + /> + + + + + Home + + + + Link + + + Dropdown button + + Action + Another action + + Something else here + + + + + Disabled + + + + + + + Search + + + + + +
    + + + Navbar + setVisible(!visible)} + /> + + + + + Home + + + + Link + + + Dropdown button + + Action + Another action + + Something else here + + + + + Disabled + + + + + + + Search + + + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarContainers2Example.tsx b/packages/docs/content/components/navbar/examples/NavbarContainers2Example.tsx new file mode 100644 index 00000000..ed6e3978 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarContainers2Example.tsx @@ -0,0 +1,12 @@ +import React from 'react' +import { CContainer, CNavbar, CNavbarBrand } from '@coreui/react' + +export const NavbarContainers2Example = () => { + return ( + + + Navbar + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarContainersExample.tsx b/packages/docs/content/components/navbar/examples/NavbarContainersExample.tsx new file mode 100644 index 00000000..dbe22b98 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarContainersExample.tsx @@ -0,0 +1,14 @@ +import React from 'react' +import { CContainer, CNavbar, CNavbarBrand } from '@coreui/react' + +export const NavbarContainersExample = () => { + return ( + + + + Navbar + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarExample.tsx b/packages/docs/content/components/navbar/examples/NavbarExample.tsx new file mode 100644 index 00000000..2376135f --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarExample.tsx @@ -0,0 +1,63 @@ +import React, { useState } from 'react' +import { + CButton, + CCollapse, + CContainer, + CDropdown, + CDropdownDivider, + CDropdownItem, + CDropdownMenu, + CDropdownToggle, + CForm, + CFormInput, + CNavbar, + CNavbarBrand, + CNavbarNav, + CNavbarToggler, + CNavItem, + CNavLink, +} from '@coreui/react' + +export const NavbarExample = () => { + const [visible, setVisible] = useState(false) + return ( + + + Navbar + setVisible(!visible)} /> + + + + + Home + + + + Link + + + Dropdown button + + Action + Another action + + Something else here + + + + + Disabled + + + + + + + Search + + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarForms2Example.tsx b/packages/docs/content/components/navbar/examples/NavbarForms2Example.tsx new file mode 100644 index 00000000..727ff2af --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarForms2Example.tsx @@ -0,0 +1,18 @@ +import React from 'react' +import { CButton, CContainer, CForm, CFormInput, CNavbar, CNavbarBrand } from '@coreui/react' + +export const NavbarForms2Example = () => { + return ( + + + Navbar + + + + Search + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarForms3Example.tsx b/packages/docs/content/components/navbar/examples/NavbarForms3Example.tsx new file mode 100644 index 00000000..55bbf35f --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarForms3Example.tsx @@ -0,0 +1,15 @@ +import React from 'react' +import { CForm, CFormInput, CInputGroup, CInputGroupText, CNavbar } from '@coreui/react' + +export const NavbarForms3Example = () => { + return ( + + + + @ + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarForms4Example.tsx b/packages/docs/content/components/navbar/examples/NavbarForms4Example.tsx new file mode 100644 index 00000000..cf58e561 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarForms4Example.tsx @@ -0,0 +1,17 @@ +import React from 'react' +import { CButton, CForm, CNavbar } from '@coreui/react' + +export const NavbarForms4Example = () => { + return ( + + + + Main button + + + Smaller button + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarFormsExample.tsx b/packages/docs/content/components/navbar/examples/NavbarFormsExample.tsx new file mode 100644 index 00000000..2b1e28c6 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarFormsExample.tsx @@ -0,0 +1,17 @@ +import React from 'react' +import { CButton, CContainer, CForm, CFormInput, CNavbar } from '@coreui/react' + +export const NavbarFormsExample = () => { + return ( + + + + + + Search + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarNav2Example.tsx b/packages/docs/content/components/navbar/examples/NavbarNav2Example.tsx new file mode 100644 index 00000000..55711a87 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarNav2Example.tsx @@ -0,0 +1,40 @@ +import React, { useState } from 'react' +import { + CCollapse, + CContainer, + CNavbar, + CNavbarBrand, + CNavbarNav, + CNavbarToggler, + CNavLink, +} from '@coreui/react' + +export const NavbarNav2Example = () => { + const [visible, setVisible] = useState(false) + return ( + <> + + + Navbar + setVisible(!visible)} + /> + + + + Home + + Features + Pricing + + Disabled + + + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarNav3Example.tsx b/packages/docs/content/components/navbar/examples/NavbarNav3Example.tsx new file mode 100644 index 00000000..680917b9 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarNav3Example.tsx @@ -0,0 +1,58 @@ +import React, { useState } from 'react' +import { + CCollapse, + CContainer, + CDropdown, + CDropdownDivider, + CDropdownItem, + CDropdownMenu, + CDropdownToggle, + CNavbar, + CNavbarBrand, + CNavbarNav, + CNavbarToggler, + CNavItem, + CNavLink, +} from '@coreui/react' + +export const NavbarNav3Example = () => { + const [visible, setVisible] = useState(false) + return ( + <> + + + Navbar + setVisible(!visible)} + /> + + + + + Home + + + + Features + + + Pricing + + + Dropdown link + + Action + Another action + + Something else here + + + + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarNavExample.tsx b/packages/docs/content/components/navbar/examples/NavbarNavExample.tsx new file mode 100644 index 00000000..2fecb2ae --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarNavExample.tsx @@ -0,0 +1,49 @@ +import React, { useState } from 'react' +import { + CCollapse, + CContainer, + CNavbar, + CNavbarBrand, + CNavbarNav, + CNavbarToggler, + CNavItem, + CNavLink, +} from '@coreui/react' + +export const NavbarNavExample = () => { + const [visible, setVisible] = useState(false) + return ( + <> + + + Navbar + setVisible(!visible)} + /> + + + + + Home + + + + Features + + + Pricing + + + + Disabled + + + + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarPlacementExample.tsx b/packages/docs/content/components/navbar/examples/NavbarPlacementExample.tsx new file mode 100644 index 00000000..7c40977e --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarPlacementExample.tsx @@ -0,0 +1,12 @@ +import React from 'react' +import { CContainer, CNavbar, CNavbarBrand } from '@coreui/react' + +export const NavbarPlacementExample = () => { + return ( + + + Default + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarPlacementFixedBottomExample.tsx b/packages/docs/content/components/navbar/examples/NavbarPlacementFixedBottomExample.tsx new file mode 100644 index 00000000..a7d302f1 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarPlacementFixedBottomExample.tsx @@ -0,0 +1,12 @@ +import React from 'react' +import { CContainer, CNavbar, CNavbarBrand } from '@coreui/react' + +export const NavbarPlacementFixedBottomExample = () => { + return ( + + + Fixed bottom + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarPlacementFixedTopExample.tsx b/packages/docs/content/components/navbar/examples/NavbarPlacementFixedTopExample.tsx new file mode 100644 index 00000000..38ad1b61 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarPlacementFixedTopExample.tsx @@ -0,0 +1,12 @@ +import React from 'react' +import { CContainer, CNavbar, CNavbarBrand } from '@coreui/react' + +export const NavbarPlacementFixedTopExample = () => { + return ( + + + Fixed top + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarPlacementStickyTopExample.tsx b/packages/docs/content/components/navbar/examples/NavbarPlacementStickyTopExample.tsx new file mode 100644 index 00000000..470ac1a2 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarPlacementStickyTopExample.tsx @@ -0,0 +1,12 @@ +import React from 'react' +import { CContainer, CNavbar, CNavbarBrand } from '@coreui/react' + +export const NavbarPlacementStickyTopExample = () => { + return ( + + + Sticky top + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarResponsiveExternalContentExample.tsx b/packages/docs/content/components/navbar/examples/NavbarResponsiveExternalContentExample.tsx new file mode 100644 index 00000000..98e6b7eb --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarResponsiveExternalContentExample.tsx @@ -0,0 +1,25 @@ +import React, { useState } from 'react' +import { CCollapse, CContainer, CNavbar, CNavbarToggler } from '@coreui/react' + +export const NavbarResponsiveExternalContentExample = () => { + const [visible, setVisible] = useState(false) + return ( + <> + +
    +
    Collapsed content
    + Toggleable via the navbar brand. +
    +
    + + + setVisible(!visible)} + /> + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarResponsiveOffcanvas2Example.tsx b/packages/docs/content/components/navbar/examples/NavbarResponsiveOffcanvas2Example.tsx new file mode 100644 index 00000000..89300d73 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarResponsiveOffcanvas2Example.tsx @@ -0,0 +1,83 @@ +import React, { useState } from 'react' +import { + CButton, + CCloseButton, + CContainer, + CDropdown, + CDropdownItem, + CDropdownDivider, + CDropdownMenu, + CDropdownToggle, + CForm, + CFormInput, + CNavbar, + CNavbarBrand, + CNavbarNav, + CNavbarToggler, + CNavItem, + CNavLink, + COffcanvas, + COffcanvasBody, + COffcanvasHeader, + COffcanvasTitle, +} from '@coreui/react' + +export const NavbarResponsiveOffcanvas2Example = () => { + const [visible, setVisible] = useState(false) + return ( + + + Offcanvas navbar + setVisible(!visible)} + /> + setVisible(false)} + > + + Offcanvas + setVisible(false)} /> + + + + + + Home + + + + Link + + + Dropdown button + + Action + Another action + + Something else here + + + + + Disabled + + + + + + + Search + + + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarResponsiveOffcanvasExample.tsx b/packages/docs/content/components/navbar/examples/NavbarResponsiveOffcanvasExample.tsx new file mode 100644 index 00000000..5017ef5b --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarResponsiveOffcanvasExample.tsx @@ -0,0 +1,83 @@ +import React, { useState } from 'react' +import { + CButton, + CCloseButton, + CContainer, + CDropdown, + CDropdownItem, + CDropdownDivider, + CDropdownMenu, + CDropdownToggle, + CForm, + CFormInput, + CNavbar, + CNavbarBrand, + CNavbarNav, + CNavbarToggler, + CNavItem, + CNavLink, + COffcanvas, + COffcanvasBody, + COffcanvasHeader, + COffcanvasTitle, +} from '@coreui/react' + +export const NavbarResponsiveOffcanvasExample = () => { + const [visible, setVisible] = useState(false) + return ( + + + Offcanvas navbar + setVisible(!visible)} + /> + setVisible(false)} + > + + Offcanvas + setVisible(false)} /> + + + + + + Home + + + + Link + + + Dropdown button + + Action + Another action + + Something else here + + + + + Disabled + + + + + + + Search + + + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarResponsiveToggler2Example.tsx b/packages/docs/content/components/navbar/examples/NavbarResponsiveToggler2Example.tsx new file mode 100644 index 00000000..21d7c752 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarResponsiveToggler2Example.tsx @@ -0,0 +1,55 @@ +import React, { useState } from 'react' +import { + CButton, + CCollapse, + CContainer, + CForm, + CFormInput, + CNavbar, + CNavbarBrand, + CNavbarNav, + CNavbarToggler, + CNavItem, + CNavLink, +} from '@coreui/react' + +export const NavbarResponsiveToggler2Example = () => { + const [visible, setVisible] = useState(false) + return ( + <> + + + Navbar + setVisible(!visible)} + /> + + + + + Home + + + + Link + + + + Disabled + + + + + + + Search + + + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarResponsiveToggler3Example.tsx b/packages/docs/content/components/navbar/examples/NavbarResponsiveToggler3Example.tsx new file mode 100644 index 00000000..df353538 --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarResponsiveToggler3Example.tsx @@ -0,0 +1,55 @@ +import React, { useState } from 'react' +import { + CButton, + CCollapse, + CContainer, + CForm, + CFormInput, + CNavbar, + CNavbarBrand, + CNavbarNav, + CNavbarToggler, + CNavItem, + CNavLink, +} from '@coreui/react' + +export const NavbarResponsiveToggler3Example = () => { + const [visible, setVisible] = useState(false) + return ( + <> + + + setVisible(!visible)} + /> + Navbar + + + + + Home + + + + Link + + + + Disabled + + + + + + + Search + + + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarResponsiveTogglerExample.tsx b/packages/docs/content/components/navbar/examples/NavbarResponsiveTogglerExample.tsx new file mode 100644 index 00000000..21abfd2a --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarResponsiveTogglerExample.tsx @@ -0,0 +1,55 @@ +import React, { useState } from 'react' +import { + CButton, + CCollapse, + CContainer, + CForm, + CFormInput, + CNavbar, + CNavbarBrand, + CNavbarNav, + CNavbarToggler, + CNavItem, + CNavLink, +} from '@coreui/react' + +export const NavbarResponsiveTogglerExample = () => { + const [visible, setVisible] = useState(false) + return ( + <> + + + setVisible(!visible)} + /> + + Hidden brand + + + + Home + + + + Link + + + + Disabled + + + + + + + Search + + + + + + + ) +} diff --git a/packages/docs/content/components/navbar/examples/NavbarText.tsx b/packages/docs/content/components/navbar/examples/NavbarText.tsx new file mode 100644 index 00000000..b015c47a --- /dev/null +++ b/packages/docs/content/components/navbar/examples/NavbarText.tsx @@ -0,0 +1,12 @@ +import React from 'react' +import { CContainer, CNavbar, CNavbarText } from '@coreui/react' + +export const NavbarText = () => { + return ( + + + Navbar text with an inline element + + + ) +} diff --git a/packages/docs/content/components/navbar/index.mdx b/packages/docs/content/components/navbar/index.mdx new file mode 100644 index 00000000..6356d37c --- /dev/null +++ b/packages/docs/content/components/navbar/index.mdx @@ -0,0 +1,154 @@ +--- +title: React Navbar Component +name: Navbar +description: Documentation and examples for the React navbar powerful, responsive navigation header component. Includes support for branding, links, dropdowns, and more. +route: /components/navbar/ +other_frameworks: navbar +--- + +## Supported content + +`` come with built-in support for a handful of sub-components. Choose from the following as needed: + +- `` for your company, product, or project name. +- `` for a full-height and lightweight navigation (including support for dropdowns). +- `` for use with our collapse plugin and other [navigation toggling](#responsive-behaviors) behaviors. +- Flex and spacing utilities for any form controls and actions. +- `` for adding vertically centered strings of text. +- `` for grouping and hiding navbar contents by a parent breakpoint. + +Here's an example of all the sub-components included in a responsive light-themed navbar that automatically collapses at the `lg` (large) breakpoint. + +## Basic usage + + + +### Brand + +The `` can be applied to most elements, but an anchor works best, as some elements might require utility classes or custom styles. + + + +Adding images to the `` will likely always require custom styles or utilities to properly size. Here are some examples to demonstrate. + + + + + +### Nav + +`` navigation is based on ``. **Navigation in navbars will also grow to occupy as much horizontal space as possible** to keep your navbar contents securely aligned. + + + +And because we use classes for our navs, you can avoid the list-based approach entirely if you like. + + + +You can also use dropdowns in your navbar. Please note that `` component requires `variant="nav-item"`. + + + +### Forms + +Place various form controls and components within a navbar: + + + +Immediate child elements of `` use flex layout and will default to `justify-content: space-between`. Use additional [flex utilities](https://coreui.io/bootstrap/docs/utilities/flex/) as needed to adjust this behavior. + + + +Input groups work, too. If your navbar is an entire form, or mostly a form, you can use the `` element as the container and save some HTML. + + + +Various buttons are supported as part of these navbar forms, too. This is also a great reminder that vertical alignment utilities can be used to align different sized elements. + + + +### Text + +Navbars may contain bits of text with the help of ``. This class adjusts vertical alignment and horizontal spacing for strings of text. + + + +## Color schemes + +Theming the navbar has never been easier thanks to the combination of theming classes and `background-color` utilities. Set `colorScheme="light"` for use with light background colors, or `colorScheme="dark"` for dark background colors. Then, customize with `.bg-*` utilities. + + + +## Containers + +Although it's not required, you can wrap a `` in a `` to center it on a page–though note that an inner container is still required. Or you can add a container inside the `` to only center the contents of a [fixed or static top navbar](#placement). + + + +Use any of the responsive containers to change how wide the content in your navbar is presented. + + + +## Placement + +Use our `placement` properly to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, or stickied to the top (scrolls with the page until it reaches the top, then stays there). Fixed navbars use `position: fixed`, meaning they're pulled from the normal flow of the DOM and may require custom CSS (e.g., `padding-top` on the ``) to prevent overlap with other elements. + +Also note that **`.sticky-top` uses `position: sticky`, which [isn't fully supported in every browser](https://caniuse.com/css-sticky)**. + + + + + + + + + +## Responsive behaviors + +Navbars can use ``, ``, and `expand="{sm|md|lg|xl|xxl}"` property to determine when their content collapses behind a button. In combination with other utilities, you can easily choose when to show or hide particular elements. + +For navbars that never collapse, add the `expand` boolean property on the ``. For navbars that always collapse, don't add any property. + +### Toggler + +Navbar togglers are left-aligned by default, but should they follow a sibling element like a ``, they'll automatically be aligned to the far right. Reversing your markup will reverse the placement of the toggler. Below are examples of different toggle styles. + +With no `` shown at the smallest breakpoint: + + + +With a brand name shown on the left and toggler on the right: + + + +With a toggler on the left and brand name on the right: + + + +### External content + +Sometimes you want to use the collapse plugin to trigger a container element for content that structurally sits outside of the ``. + + + +### Offcanvas + +Transform your expanding and collapsing navbar into an offcanvas drawer with the offcanvas plugin. We extend both the offcanvas default styles and use our `expand="*"` prop to create a dynamic and flexible navigation sidebar. + +In the example below, to create an offcanvas navbar that is always collapsed across all breakpoints, omit the `expand="*"` prop entirely. + + + +To create an offcanvas navbar that expands into a normal navbar at a specific breakpoint like `xxl`, use `expand="xxl"` property. + + + +## API + +Check out the documentation below for a comprehensive guide to all the props you can use with the components mentioned here. + +- [<CNavbar />](./api/#cnavbar) +- [<CNavbarBrand />](./api/#cnavbarbrand) +- [<CNavbarNav />](./api/#cnavbarnav) +- [<CNavbarText />](./api/#cnavbartext) +- [<CNavbarToggler />](./api/#cnavbartoggler) \ No newline at end of file diff --git a/packages/docs/content/components/navbar/styling.mdx b/packages/docs/content/components/navbar/styling.mdx new file mode 100644 index 00000000..f3f41df9 --- /dev/null +++ b/packages/docs/content/components/navbar/styling.mdx @@ -0,0 +1,47 @@ +--- +title: React Navbar Component Styling +name: Navbar Styling +description: Learn how to customize the React Navbar component with CSS classes, variables, and SASS for flexible styling and seamless integration into your design. +route: /components/navbar/ +--- + +### CSS variables + +React navbars use local CSS variables on `.navbar` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too. + + + +Some additional CSS variables are also present on `.navbar-nav`: + + + +Customization through CSS variables can be seen on the `.navbar-dark` class where we override specific values without adding duplicate CSS selectors. + + + +#### How to use CSS variables + +```jsx +const customVars = { + '--cui-navbar-color': '#24e484', + '--cui-navbar-hover-color': '1a1a1a', +} + +return {/* Navbar content */} +``` + +### SASS variables + +Variables for all navbars: + + + +Variables for the [dark navbar](#color-schemes): + + + +### SASS loops + +[Responsive navbar expand/collapse classes](#responsive-behaviors) (e.g., `.navbar-expand-lg`) are combined with the `$breakpoints` map and generated through a loop in `scss/_navbar.scss`. + + diff --git a/packages/docs/content/components/navs-tabs.mdx b/packages/docs/content/components/navs-tabs.mdx deleted file mode 100644 index 86f52b5c..00000000 --- a/packages/docs/content/components/navs-tabs.mdx +++ /dev/null @@ -1,719 +0,0 @@ ---- -title: React Navs & Tabs Components -name: Navs & Tabs -description: Documentation and examples for how to use CoreUI's included React navigation components. -menu: Components -route: /components/navs-tabs -other_frameworks: navs-tabs ---- - -import { useState } from 'react' - -import { - CDropdown, - CDropdownDivider, - CDropdownHeader, - CDropdownItem, - CDropdownItemPlain, - CDropdownMenu, - CDropdownToggle, - CNav, - CNavItem, - CNavLink, - CTabContent, - CTabPane, -} from '@coreui/react/src/index' - -## Base nav - -Navigation available in CoreUI for React share general markup and styles, from the base `.nav` class to the active and disabled states. Swap modifier classes to switch between each style. - -The base `` component is built with flexbox and provide a strong foundation for building all types of navigation components. It includes some style overrides (for working with lists), some link padding for larger hit areas, and basic disabled styling. - -```jsx preview - - - - Active - - - - Link - - - Link - - - - Disabled - - - -``` - -Classes are used throughout, so your markup can be super flexible. Use `