@shohojdhara/atomix 0.1.30 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -0
- package/LICENSE +0 -0
- package/README.md +128 -43
- package/dist/atomix.css +15025 -0
- package/dist/atomix.min.css +15 -0
- package/dist/index.d.ts +6459 -1748
- package/dist/index.esm.js +17559 -8364
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +17603 -8369
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/themes/boomdevs.css +14677 -0
- package/dist/themes/boomdevs.min.css +405 -0
- package/dist/themes/esrar.css +16870 -0
- package/dist/themes/esrar.min.css +189 -0
- package/dist/themes/mashroom.css +29578 -0
- package/dist/themes/mashroom.min.css +403 -0
- package/dist/themes/shaj-default.css +15702 -0
- package/dist/themes/shaj-default.min.css +500 -0
- package/dist/themes/yabai.css +15207 -0
- package/dist/themes/yabai.min.css +189 -0
- package/package.json +126 -99
- package/src/components/Accordion/Accordion.stories.tsx +271 -0
- package/src/components/Accordion/Accordion.tsx +131 -0
- package/src/components/Accordion/index.ts +3 -0
- package/src/components/AtomixLogo/AtomixLogo.tsx +36 -0
- package/src/components/AtomixLogo/index.ts +3 -0
- package/src/components/AtomixLogo.tsx +40 -0
- package/src/components/Avatar/Avatar.stories.tsx +257 -0
- package/src/components/Avatar/Avatar.tsx +68 -0
- package/src/components/Avatar/AvatarGroup.tsx +73 -0
- package/src/components/Avatar/index.ts +3 -0
- package/src/components/Badge/Badge.stories.tsx +371 -0
- package/src/components/Badge/Badge.tsx +39 -0
- package/src/components/Badge/index.ts +3 -0
- package/src/components/Block/Block.stories.tsx +408 -0
- package/src/components/Block/Block.tsx +137 -0
- package/src/components/Block/index.ts +1 -0
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +106 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +112 -0
- package/src/components/Breadcrumb/index.ts +3 -0
- package/src/components/Button/Button.stories.tsx +312 -0
- package/src/components/Button/Button.tsx +69 -0
- package/src/components/Button/index.ts +3 -0
- package/src/components/Callout/Callout.stories.tsx +588 -0
- package/src/components/Callout/Callout.tsx +78 -0
- package/src/components/Callout/index.ts +1 -0
- package/src/components/Card/Card.stories.tsx +105 -0
- package/src/components/Card/Card.tsx +69 -0
- package/src/components/Card/ElevationCard.tsx +47 -0
- package/src/components/Card/index.ts +15 -0
- package/src/components/Chart/AdvancedChart.tsx +624 -0
- package/src/components/Chart/AnimatedChart.tsx +206 -0
- package/src/components/Chart/AreaChart.tsx +27 -0
- package/src/components/Chart/BarChart.tsx +148 -0
- package/src/components/Chart/BubbleChart.tsx +411 -0
- package/src/components/Chart/CandlestickChart.tsx +765 -0
- package/src/components/Chart/Chart.stories.tsx +527 -0
- package/src/components/Chart/Chart.tsx +218 -0
- package/src/components/Chart/ChartRenderer.tsx +322 -0
- package/src/components/Chart/ChartToolbar.tsx +436 -0
- package/src/components/Chart/ChartTooltip.tsx +101 -0
- package/src/components/Chart/DonutChart.tsx +370 -0
- package/src/components/Chart/FunnelChart.tsx +393 -0
- package/src/components/Chart/GaugeChart.tsx +550 -0
- package/src/components/Chart/HeatmapChart.tsx +614 -0
- package/src/components/Chart/LineChart.tsx +172 -0
- package/src/components/Chart/LineChartNew.tsx +167 -0
- package/src/components/Chart/MultiAxisChart.tsx +498 -0
- package/src/components/Chart/PieChart.tsx +103 -0
- package/src/components/Chart/RadarChart.tsx +332 -0
- package/src/components/Chart/RealTimeChart.tsx +436 -0
- package/src/components/Chart/ScatterChart.tsx +152 -0
- package/src/components/Chart/TreemapChart.tsx +574 -0
- package/src/components/Chart/WaterfallChart.tsx +450 -0
- package/src/components/Chart/index.ts +119 -0
- package/src/components/Chart/types.ts +338 -0
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +44 -0
- package/src/components/ColorModeToggle/ColorModeToggle.tsx +85 -0
- package/src/components/ColorModeToggle/index.ts +2 -0
- package/src/components/Countdown/Countdown.stories.tsx +46 -0
- package/src/components/Countdown/Countdown.tsx +90 -0
- package/src/components/Countdown/index.ts +2 -0
- package/src/components/DataTable/DataTable.stories.tsx +248 -0
- package/src/components/DataTable/DataTable.tsx +213 -0
- package/src/components/DataTable/index.ts +3 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +364 -0
- package/src/components/DatePicker/DatePicker.tsx +504 -0
- package/src/components/DatePicker/index.ts +4 -0
- package/src/components/DatePicker/readme.md +106 -0
- package/src/components/DatePicker/types.ts +167 -0
- package/src/components/DatePicker/utils.ts +185 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +358 -0
- package/src/components/Dropdown/Dropdown.tsx +352 -0
- package/src/components/Dropdown/index.ts +14 -0
- package/src/components/Dropdown/readme.md +151 -0
- package/src/components/EdgePanel/EdgePanel.stories.tsx +266 -0
- package/src/components/EdgePanel/EdgePanel.tsx +73 -0
- package/src/components/EdgePanel/index.ts +1 -0
- package/src/components/Footer/Footer.stories.tsx +388 -0
- package/src/components/Footer/Footer.tsx +197 -0
- package/src/components/Footer/FooterLink.tsx +72 -0
- package/src/components/Footer/FooterSection.tsx +87 -0
- package/src/components/Footer/FooterSocialLink.tsx +117 -0
- package/src/components/Footer/README.md +261 -0
- package/src/components/Footer/index.ts +13 -0
- package/src/components/Form/Checkbox.stories.tsx +76 -0
- package/src/components/Form/Checkbox.tsx +69 -0
- package/src/components/Form/Form.stories.tsx +497 -0
- package/src/components/Form/Form.tsx +46 -0
- package/src/components/Form/FormGroup.stories.tsx +162 -0
- package/src/components/Form/FormGroup.tsx +53 -0
- package/src/components/Form/Input.stories.tsx +106 -0
- package/src/components/Form/Input.tsx +87 -0
- package/src/components/Form/Radio.stories.tsx +94 -0
- package/src/components/Form/Radio.tsx +65 -0
- package/src/components/Form/Select.stories.tsx +151 -0
- package/src/components/Form/Select.tsx +191 -0
- package/src/components/Form/Textarea.stories.tsx +123 -0
- package/src/components/Form/Textarea.tsx +78 -0
- package/src/components/Form/index.ts +7 -0
- package/src/components/Hero/Hero.stories.tsx +295 -0
- package/src/components/Hero/Hero.tsx +175 -0
- package/src/components/Hero/index.ts +6 -0
- package/src/components/Icon/Icon.tsx +87 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/List/List.stories.tsx +122 -0
- package/src/components/List/List.tsx +35 -0
- package/src/components/List/ListGroup.tsx +35 -0
- package/src/components/List/index.ts +2 -0
- package/src/components/Messages/Messages.stories.tsx +160 -0
- package/src/components/Messages/Messages.tsx +172 -0
- package/src/components/Messages/index.ts +3 -0
- package/src/components/Modal/Modal.stories.tsx +284 -0
- package/src/components/Modal/Modal.tsx +198 -0
- package/src/components/Modal/README.md +169 -0
- package/src/components/Modal/index.ts +1 -0
- package/src/components/Navigation/Menu/MegaMenu.tsx +109 -0
- package/src/components/Navigation/Menu/Menu.stories.tsx +339 -0
- package/src/components/Navigation/Menu/Menu.tsx +111 -0
- package/src/components/Navigation/Nav/Nav.stories.tsx +456 -0
- package/src/components/Navigation/Nav/Nav.tsx +51 -0
- package/src/components/Navigation/Nav/NavDropdown.tsx +105 -0
- package/src/components/Navigation/Nav/NavItem.tsx +168 -0
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +569 -0
- package/src/components/Navigation/Navbar/Navbar.tsx +150 -0
- package/src/components/Navigation/README.md +314 -0
- package/src/components/Navigation/SideMenu/SideMenu.README.md +494 -0
- package/src/components/Navigation/SideMenu/SideMenu.stories.tsx +609 -0
- package/src/components/Navigation/SideMenu/SideMenu.tsx +101 -0
- package/src/components/Navigation/SideMenu/SideMenuItem.tsx +103 -0
- package/src/components/Navigation/SideMenu/SideMenuList.tsx +41 -0
- package/src/components/Navigation/index.ts +23 -0
- package/src/components/Pagination/Pagination.stories.tsx +188 -0
- package/src/components/Pagination/Pagination.tsx +162 -0
- package/src/components/Pagination/index.ts +1 -0
- package/src/components/PhotoViewer/PhotoViewer.stories.tsx +397 -0
- package/src/components/PhotoViewer/PhotoViewer.tsx +246 -0
- package/src/components/PhotoViewer/PhotoViewerHeader.tsx +184 -0
- package/src/components/PhotoViewer/PhotoViewerImage.tsx +173 -0
- package/src/components/PhotoViewer/PhotoViewerInfo.tsx +91 -0
- package/src/components/PhotoViewer/PhotoViewerNavigation.tsx +85 -0
- package/src/components/PhotoViewer/PhotoViewerThumbnails.tsx +63 -0
- package/src/components/PhotoViewer/README.md +358 -0
- package/src/components/PhotoViewer/examples/ImageGallery.tsx +187 -0
- package/src/components/PhotoViewer/examples/SimpleGallery.tsx +73 -0
- package/src/components/PhotoViewer/examples/index.ts +2 -0
- package/src/components/PhotoViewer/index.ts +14 -0
- package/src/components/Popover/Popover.stories.tsx +143 -0
- package/src/components/Popover/Popover.tsx +137 -0
- package/src/components/Popover/index.ts +5 -0
- package/src/components/Popover/readme.md +120 -0
- package/src/components/ProductReview/ProductReview.stories.tsx +88 -0
- package/src/components/ProductReview/ProductReview.tsx +169 -0
- package/src/components/ProductReview/index.ts +3 -0
- package/src/components/Progress/Progress.stories.tsx +75 -0
- package/src/components/Progress/Progress.tsx +45 -0
- package/src/components/Progress/index.ts +1 -0
- package/src/components/Rating/Rating.stories.tsx +109 -0
- package/src/components/Rating/Rating.tsx +286 -0
- package/src/components/Rating/index.ts +6 -0
- package/src/components/River/River.stories.tsx +230 -0
- package/src/components/River/River.tsx +134 -0
- package/src/components/River/index.ts +2 -0
- package/src/components/SectionIntro/SectionIntro.stories.tsx +143 -0
- package/src/components/SectionIntro/SectionIntro.tsx +182 -0
- package/src/components/SectionIntro/index.ts +3 -0
- package/src/components/Slider/Slider.stories.tsx +825 -0
- package/src/components/Slider/Slider.tsx +227 -0
- package/src/components/Slider/index.ts +24 -0
- package/src/components/Spinner/Spinner.stories.tsx +65 -0
- package/src/components/Spinner/Spinner.tsx +36 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/Steps/Steps.stories.tsx +158 -0
- package/src/components/Steps/Steps.tsx +115 -0
- package/src/components/Steps/index.ts +3 -0
- package/src/components/Tab/Tab.stories.tsx +129 -0
- package/src/components/Tab/Tab.tsx +111 -0
- package/src/components/Tab/index.ts +2 -0
- package/src/components/Testimonial/Testimonial.stories.tsx +180 -0
- package/src/components/Testimonial/Testimonial.tsx +138 -0
- package/src/components/Testimonial/index.ts +3 -0
- package/src/components/Todo/Todo.stories.tsx +103 -0
- package/src/components/Todo/Todo.tsx +158 -0
- package/src/components/Todo/index.ts +1 -0
- package/src/components/Toggle/Toggle.stories.tsx +49 -0
- package/src/components/Toggle/Toggle.tsx +84 -0
- package/src/components/Toggle/index.ts +2 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +115 -0
- package/src/components/Tooltip/Tooltip.tsx +150 -0
- package/src/components/Tooltip/index.ts +3 -0
- package/src/components/Upload/Upload.stories.tsx +220 -0
- package/src/components/Upload/Upload.tsx +354 -0
- package/src/components/Upload/index.ts +3 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.tsx +484 -0
- package/src/components/VideoPlayer/VideoPlayer.tsx +574 -0
- package/src/components/VideoPlayer/index.ts +7 -0
- package/src/components/index.ts +124 -0
- package/src/layouts/Grid/Container.tsx +58 -0
- package/src/layouts/Grid/Grid.stories.tsx +928 -0
- package/src/layouts/Grid/Grid.tsx +68 -0
- package/src/layouts/Grid/GridCol.tsx +161 -0
- package/src/layouts/Grid/README.md +108 -0
- package/src/layouts/Grid/Row.tsx +70 -0
- package/src/layouts/Grid/index.ts +8 -0
- package/src/layouts/MasonryGrid/MasonryGrid.stories.tsx +387 -0
- package/src/layouts/MasonryGrid/MasonryGrid.tsx +408 -0
- package/src/layouts/MasonryGrid/MasonryGridItem.tsx +44 -0
- package/src/layouts/MasonryGrid/README.md +117 -0
- package/src/layouts/MasonryGrid/index.ts +4 -0
- package/src/layouts/index.ts +7 -0
- package/src/lib/README.md +89 -0
- package/src/lib/composables/index.ts +63 -0
- package/src/lib/composables/useAccordion.ts +129 -0
- package/src/lib/composables/useAmbientMode.ts +90 -0
- package/src/lib/composables/useBadge.ts +42 -0
- package/src/lib/composables/useBarChart.ts +365 -0
- package/src/lib/composables/useBlock.ts +56 -0
- package/src/lib/composables/useBreadcrumb.ts +81 -0
- package/src/lib/composables/useButton.ts +59 -0
- package/src/lib/composables/useCallout.ts +55 -0
- package/src/lib/composables/useCard.ts +155 -0
- package/src/lib/composables/useChart.ts +1082 -0
- package/src/lib/composables/useChartAnalytics.ts +505 -0
- package/src/lib/composables/useChartData.ts +38 -0
- package/src/lib/composables/useChartExport.ts +392 -0
- package/src/lib/composables/useChartInteraction.ts +34 -0
- package/src/lib/composables/useChartInteractions.ts +123 -0
- package/src/lib/composables/useChartPerformance.ts +323 -0
- package/src/lib/composables/useChartScale.ts +48 -0
- package/src/lib/composables/useChartToolbar.ts +532 -0
- package/src/lib/composables/useCheckbox.ts +70 -0
- package/src/lib/composables/useDataTable.ts +208 -0
- package/src/lib/composables/useDatePicker.ts +564 -0
- package/src/lib/composables/useDropdown.ts +272 -0
- package/src/lib/composables/useEdgePanel.ts +261 -0
- package/src/lib/composables/useFooter.ts +85 -0
- package/src/lib/composables/useForm.ts +62 -0
- package/src/lib/composables/useFormGroup.ts +51 -0
- package/src/lib/composables/useHero.ts +250 -0
- package/src/lib/composables/useInput.ts +58 -0
- package/src/lib/composables/useLineChart.ts +319 -0
- package/src/lib/composables/useMessages.ts +77 -0
- package/src/lib/composables/useModal.ts +110 -0
- package/src/lib/composables/useNavbar.ts +288 -0
- package/src/lib/composables/usePagination.ts +101 -0
- package/src/lib/composables/usePhotoViewer.ts +937 -0
- package/src/lib/composables/usePieChart.ts +362 -0
- package/src/lib/composables/usePopover.ts +354 -0
- package/src/lib/composables/useProgress.ts +74 -0
- package/src/lib/composables/useRadio.ts +47 -0
- package/src/lib/composables/useRating.ts +174 -0
- package/src/lib/composables/useRiver.ts +205 -0
- package/src/lib/composables/useSelect.ts +52 -0
- package/src/lib/composables/useSideMenu.ts +197 -0
- package/src/lib/composables/useSlider.ts +526 -0
- package/src/lib/composables/useSpinner.ts +42 -0
- package/src/lib/composables/useTextarea.ts +55 -0
- package/src/lib/composables/useTodo.ts +141 -0
- package/src/lib/composables/useVideoPlayer.ts +398 -0
- package/src/lib/constants/components.ts +1518 -0
- package/src/lib/constants/index.ts +4 -0
- package/src/lib/index.ts +11 -0
- package/src/lib/types/components.ts +5020 -0
- package/src/lib/types/index.ts +2 -0
- package/src/lib/utils/dom.ts +41 -0
- package/src/lib/utils/icons.ts +74 -0
- package/src/lib/utils/index.ts +55 -0
- package/src/lib/utils/useForkRef.test.tsx +64 -0
- package/src/lib/utils/useForkRef.ts +36 -0
- package/src/lib/utils.test.ts +14 -0
- package/src/styles/01-settings/_index.scss +3 -0
- package/src/styles/01-settings/_settings.accordion.scss +22 -19
- package/src/styles/01-settings/_settings.animations.scss +5 -5
- package/src/styles/01-settings/_settings.avatar-group.scss +7 -4
- package/src/styles/01-settings/_settings.avatar.scss +19 -20
- package/src/styles/01-settings/_settings.background.scss +9 -0
- package/src/styles/01-settings/_settings.badge.scss +15 -9
- package/src/styles/01-settings/_settings.block.scss +11 -0
- package/src/styles/01-settings/_settings.border-radius.scss +12 -9
- package/src/styles/01-settings/_settings.border.scss +4 -1
- package/src/styles/01-settings/_settings.box-shadow.scss +1 -1
- package/src/styles/01-settings/_settings.breadcrumb.scss +16 -9
- package/src/styles/01-settings/_settings.breakpoints.scss +0 -0
- package/src/styles/01-settings/_settings.btn-group.scss +4 -1
- package/src/styles/01-settings/_settings.button.scss +19 -21
- package/src/styles/01-settings/_settings.callout.scss +42 -24
- package/src/styles/01-settings/_settings.card.scss +13 -11
- package/src/styles/01-settings/_settings.chart.scss +199 -0
- package/src/styles/01-settings/_settings.checkbox-group.scss +5 -2
- package/src/styles/01-settings/_settings.checkbox.scss +10 -4
- package/src/styles/01-settings/_settings.color-mode.scss +0 -0
- package/src/styles/01-settings/_settings.colors.scss +20 -0
- package/src/styles/01-settings/_settings.config.scss +1 -1
- package/src/styles/01-settings/_settings.countdown.scss +6 -4
- package/src/styles/01-settings/_settings.data-table.scss +0 -0
- package/src/styles/01-settings/_settings.datepicker.scss +0 -0
- package/src/styles/01-settings/_settings.dropdown.scss +9 -7
- package/src/styles/01-settings/_settings.edge-panel.scss +3 -2
- package/src/styles/01-settings/_settings.fonts.scss +1 -1
- package/src/styles/01-settings/_settings.footer.scss +125 -0
- package/src/styles/01-settings/_settings.form-group.scss +3 -1
- package/src/styles/01-settings/_settings.form.scss +4 -2
- package/src/styles/01-settings/_settings.grid.scss +3 -3
- package/src/styles/01-settings/_settings.hero.scss +10 -8
- package/src/styles/01-settings/_settings.input.scss +9 -7
- package/src/styles/01-settings/_settings.link.scss +0 -0
- package/src/styles/01-settings/_settings.list-group.scss +4 -2
- package/src/styles/01-settings/_settings.list.scss +4 -2
- package/src/styles/01-settings/_settings.maps.scss +43 -8
- package/src/styles/01-settings/_settings.masonry-grid.scss +0 -0
- package/src/styles/01-settings/_settings.menu.scss +10 -8
- package/src/styles/01-settings/_settings.messages.scss +19 -17
- package/src/styles/01-settings/_settings.modal.scss +7 -5
- package/src/styles/01-settings/_settings.nav.scss +6 -4
- package/src/styles/01-settings/_settings.navbar.scss +8 -5
- package/src/styles/01-settings/_settings.pagination.scss +5 -3
- package/src/styles/01-settings/_settings.photoviewer.scss +89 -23
- package/src/styles/01-settings/_settings.popover.scss +6 -4
- package/src/styles/01-settings/_settings.position.scss +0 -0
- package/src/styles/01-settings/_settings.progress.scss +0 -0
- package/src/styles/01-settings/_settings.rating.scss +5 -3
- package/src/styles/01-settings/_settings.river.scss +8 -6
- package/src/styles/01-settings/_settings.sectionintro.scss +8 -6
- package/src/styles/01-settings/_settings.select.scss +7 -5
- package/src/styles/01-settings/_settings.side-menu.scss +15 -13
- package/src/styles/01-settings/_settings.skeleton.scss +0 -0
- package/src/styles/01-settings/_settings.slider.scss +59 -0
- package/src/styles/01-settings/_settings.spacing.scss +15 -3
- package/src/styles/01-settings/_settings.spinner.scss +0 -0
- package/src/styles/01-settings/_settings.steps.scss +8 -6
- package/src/styles/01-settings/_settings.tabs.scss +11 -9
- package/src/styles/01-settings/_settings.testimonials.scss +6 -4
- package/src/styles/01-settings/_settings.todo.scss +0 -0
- package/src/styles/01-settings/_settings.toggle.scss +4 -2
- package/src/styles/01-settings/_settings.tooltip.scss +5 -3
- package/src/styles/01-settings/_settings.typography.scss +2 -0
- package/src/styles/01-settings/_settings.upload.scss +22 -20
- package/src/styles/01-settings/_settings.video-player.scss +64 -0
- package/src/styles/01-settings/_settings.z-layers.scss +0 -0
- package/src/styles/02-tools/_index.scss +1 -0
- package/src/styles/02-tools/_tools.animations.scss +82 -0
- package/src/styles/02-tools/_tools.background.scss +85 -0
- package/src/styles/02-tools/_tools.border-radius.scss +0 -0
- package/src/styles/02-tools/_tools.breakpoints.scss +0 -0
- package/src/styles/02-tools/_tools.button.scss +5 -0
- package/src/styles/02-tools/_tools.clearfix.scss +0 -0
- package/src/styles/02-tools/_tools.color-functions.scss +0 -0
- package/src/styles/02-tools/_tools.color-mode.scss +1 -1
- package/src/styles/02-tools/_tools.component.scss +479 -0
- package/src/styles/02-tools/_tools.event.scss +0 -0
- package/src/styles/02-tools/_tools.grid.scss +0 -0
- package/src/styles/02-tools/_tools.hidden-visually.scss +0 -0
- package/src/styles/02-tools/_tools.hidden.scss +0 -0
- package/src/styles/02-tools/_tools.map-loop.scss +0 -0
- package/src/styles/02-tools/_tools.media-queries.scss +0 -0
- package/src/styles/02-tools/_tools.object-fit.scss +0 -0
- package/src/styles/02-tools/_tools.placeholder.scss +0 -0
- package/src/styles/02-tools/_tools.rem.scss +19 -2
- package/src/styles/02-tools/_tools.size.scss +0 -0
- package/src/styles/02-tools/_tools.spacing.scss +0 -0
- package/src/styles/02-tools/_tools.to-rgb.scss +0 -0
- package/src/styles/02-tools/_tools.transition.scss +0 -0
- package/src/styles/02-tools/_tools.utilities.scss +0 -0
- package/src/styles/02-tools/_tools.utility-api.scss +55 -28
- package/src/styles/03-generic/_generic.fonts.scss +0 -0
- package/src/styles/03-generic/_generic.reset.scss +0 -0
- package/src/styles/03-generic/_generic.root.scss +19 -3
- package/src/styles/03-generic/_generic.selection.scss +0 -0
- package/src/styles/03-generic/_index.scss +0 -0
- package/src/styles/04-elements/_elements.all.scss +0 -0
- package/src/styles/04-elements/_elements.body.scss +24 -0
- package/src/styles/04-elements/_elements.heading.scss +0 -0
- package/src/styles/04-elements/_elements.html.scss +0 -0
- package/src/styles/04-elements/_elements.links.scss +0 -0
- package/src/styles/04-elements/_index.scss +0 -0
- package/src/styles/05-objects/_index.scss +1 -0
- package/src/styles/05-objects/_objects.block.scss +122 -0
- package/src/styles/05-objects/_objects.container.scss +14 -10
- package/src/styles/05-objects/_objects.grid.scss +0 -0
- package/src/styles/05-objects/_objects.masonry-grid.scss +0 -0
- package/src/styles/06-components/_components.accordion.scss +10 -4
- package/src/styles/06-components/_components.avatar-group.scss +2 -1
- package/src/styles/06-components/_components.avatar.scss +2 -1
- package/src/styles/06-components/_components.badge.scss +11 -10
- package/src/styles/06-components/_components.breadcrumb.scss +2 -1
- package/src/styles/06-components/_components.btn-group.scss +0 -0
- package/src/styles/06-components/_components.button.scss +4 -3
- package/src/styles/06-components/_components.callout.scss +5 -3
- package/src/styles/06-components/_components.card.scss +4 -3
- package/src/styles/06-components/_components.chart.scss +2103 -0
- package/src/styles/06-components/_components.checkbox-group.scss +0 -0
- package/src/styles/06-components/_components.checkbox.scss +2 -1
- package/src/styles/06-components/_components.color-mode-toggle.scss +3 -2
- package/src/styles/06-components/_components.countdown.scss +2 -1
- package/src/styles/06-components/_components.data-table.scss +7 -6
- package/src/styles/06-components/_components.datepicker.scss +2 -1
- package/src/styles/06-components/_components.dropdown.scss +4 -3
- package/src/styles/06-components/_components.edge-panel.scss +4 -3
- package/src/styles/06-components/_components.footer.scss +825 -0
- package/src/styles/06-components/_components.form-group.scss +1 -0
- package/src/styles/06-components/_components.form.scss +0 -0
- package/src/styles/06-components/_components.hero.scss +4 -2
- package/src/styles/06-components/_components.icon.scss +2 -2
- package/src/styles/06-components/_components.image-gallery.scss +1 -0
- package/src/styles/06-components/_components.input.scss +2 -1
- package/src/styles/06-components/_components.list-group.scss +3 -2
- package/src/styles/06-components/_components.list.scss +2 -1
- package/src/styles/06-components/_components.menu.scss +5 -4
- package/src/styles/06-components/_components.messages.scss +8 -7
- package/src/styles/06-components/_components.modal.scss +6 -2
- package/src/styles/06-components/_components.nav.scss +6 -5
- package/src/styles/06-components/_components.navbar.scss +4 -3
- package/src/styles/06-components/_components.pagination.scss +2 -1
- package/src/styles/06-components/_components.photoviewer.scss +604 -545
- package/src/styles/06-components/_components.popover.scss +3 -2
- package/src/styles/06-components/_components.product-review.scss +3 -2
- package/src/styles/06-components/_components.progress.scss +3 -2
- package/src/styles/06-components/_components.rating.scss +0 -0
- package/src/styles/06-components/_components.river.scss +3 -2
- package/src/styles/06-components/_components.sectionintro.scss +2 -1
- package/src/styles/06-components/_components.select.scss +5 -4
- package/src/styles/06-components/_components.side-menu.scss +8 -7
- package/src/styles/06-components/_components.skeleton.scss +3 -2
- package/src/styles/06-components/_components.slider.scss +274 -0
- package/src/styles/06-components/_components.spinner.scss +1 -0
- package/src/styles/06-components/_components.steps.scss +4 -2
- package/src/styles/06-components/_components.tabs.scss +4 -3
- package/src/styles/06-components/_components.testimonials.scss +2 -1
- package/src/styles/06-components/_components.todo.scss +3 -2
- package/src/styles/06-components/_components.toggle.scss +5 -4
- package/src/styles/06-components/_components.tooltip.scss +7 -11
- package/src/styles/06-components/_components.upload.scss +4 -3
- package/src/styles/06-components/_components.video-player.scss +624 -0
- package/src/styles/06-components/_index.scss +4 -0
- package/src/styles/06-components/old.chart.styles.scss +2819 -0
- package/src/styles/99-utilities/_index.scss +0 -0
- package/src/styles/99-utilities/_utilities.background.scss +0 -0
- package/src/styles/99-utilities/_utilities.border.scss +0 -0
- package/src/styles/99-utilities/_utilities.clearfix.scss +0 -0
- package/src/styles/99-utilities/_utilities.display.scss +0 -0
- package/src/styles/99-utilities/_utilities.flex.scss +0 -0
- package/src/styles/99-utilities/_utilities.link.scss +0 -0
- package/src/styles/99-utilities/_utilities.object-fit.scss +0 -0
- package/src/styles/99-utilities/_utilities.opacity.scss +0 -0
- package/src/styles/99-utilities/_utilities.overflow.scss +0 -0
- package/src/styles/99-utilities/_utilities.position.scss +0 -0
- package/src/styles/99-utilities/_utilities.scss +2 -1
- package/src/styles/99-utilities/_utilities.shadow.scss +0 -0
- package/src/styles/99-utilities/_utilities.sizes.scss +0 -0
- package/src/styles/99-utilities/_utilities.spacing.scss +0 -0
- package/src/styles/99-utilities/_utilities.text.scss +5 -0
- package/src/styles/99-utilities/_utilities.visibility.scss +0 -0
- package/src/styles/99-utilities/_utilities.visually-hidden.scss +0 -0
- package/src/styles/99-utilities/_utilities.z-index.scss +0 -0
- package/src/styles/css-modules.d.ts +0 -0
- package/src/styles/index.scss +0 -0
- package/dist/index.css +0 -15
- package/dist/index.esm.css +0 -15
- package/dist/index.min.css +0 -15
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { TodoProps } from '../../lib/types/components';
|
|
3
|
+
import { useTodo } from '../../lib/composables/useTodo';
|
|
4
|
+
import { Icon } from '../Icon/Icon';
|
|
5
|
+
import { TODO } from '../../lib/constants/components';
|
|
6
|
+
import { generateUUID } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
export const Todo: React.FC<TodoProps> = ({
|
|
9
|
+
items = [],
|
|
10
|
+
title = 'Todo List',
|
|
11
|
+
onAddTodo,
|
|
12
|
+
onToggleTodo,
|
|
13
|
+
onDeleteTodo,
|
|
14
|
+
size = 'md',
|
|
15
|
+
placeholder = 'Add a new todo',
|
|
16
|
+
showCompleted = true,
|
|
17
|
+
className = '',
|
|
18
|
+
disabled = false,
|
|
19
|
+
}) => {
|
|
20
|
+
const { inputText, setInputText, addTodo, generateTodoClasses, generateItemClasses } = useTodo({
|
|
21
|
+
items,
|
|
22
|
+
title,
|
|
23
|
+
size,
|
|
24
|
+
placeholder,
|
|
25
|
+
showCompleted,
|
|
26
|
+
disabled,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// State to manage local items
|
|
30
|
+
const [localItems, setLocalItems] = useState(items);
|
|
31
|
+
|
|
32
|
+
// Update local items when props change
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
setLocalItems(items);
|
|
35
|
+
}, [items]);
|
|
36
|
+
|
|
37
|
+
// Handle item toggle
|
|
38
|
+
const handleToggle = (id: string) => {
|
|
39
|
+
if (disabled) return;
|
|
40
|
+
|
|
41
|
+
setLocalItems(prevItems =>
|
|
42
|
+
prevItems.map(item => (item.id === id ? { ...item, completed: !item.completed } : item))
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (onToggleTodo) {
|
|
46
|
+
onToggleTodo(id);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Handle item delete
|
|
51
|
+
const handleDelete = (id: string) => {
|
|
52
|
+
if (disabled) return;
|
|
53
|
+
|
|
54
|
+
setLocalItems(prevItems => prevItems.filter(item => item.id !== id));
|
|
55
|
+
|
|
56
|
+
if (onDeleteTodo) {
|
|
57
|
+
onDeleteTodo(id);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Handle form submission
|
|
62
|
+
const handleFormSubmit = (e: React.FormEvent) => {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
if (disabled || !inputText.trim()) return;
|
|
65
|
+
|
|
66
|
+
// Create a new todo item with a unique ID
|
|
67
|
+
const newTodo = {
|
|
68
|
+
id: generateUUID(),
|
|
69
|
+
text: inputText.trim(),
|
|
70
|
+
completed: false,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Update local state
|
|
74
|
+
setLocalItems(prevItems => [...prevItems, newTodo]);
|
|
75
|
+
|
|
76
|
+
// Call parent callback if provided
|
|
77
|
+
if (onAddTodo) {
|
|
78
|
+
onAddTodo(inputText);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Clear the input field
|
|
82
|
+
setInputText('');
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Filter items based on showCompleted prop
|
|
86
|
+
const filteredItems = showCompleted ? localItems : localItems.filter(item => !item.completed);
|
|
87
|
+
|
|
88
|
+
// Generate component classes
|
|
89
|
+
const todoClass = generateTodoClasses({ size, className, disabled });
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div className={todoClass}>
|
|
93
|
+
{title && <h2 className="c-todo__title">{title}</h2>}
|
|
94
|
+
|
|
95
|
+
<form className="c-todo__form" onSubmit={handleFormSubmit}>
|
|
96
|
+
<div className="c-todo__form-group">
|
|
97
|
+
<input
|
|
98
|
+
type="text"
|
|
99
|
+
className="c-todo__input c-input"
|
|
100
|
+
placeholder={placeholder}
|
|
101
|
+
value={inputText}
|
|
102
|
+
onChange={e => setInputText(e.target.value)}
|
|
103
|
+
disabled={disabled}
|
|
104
|
+
aria-label="Add a new todo"
|
|
105
|
+
/>
|
|
106
|
+
<button
|
|
107
|
+
type="submit"
|
|
108
|
+
className="c-todo__add-btn c-btn c-btn--primary"
|
|
109
|
+
disabled={disabled || !inputText.trim()}
|
|
110
|
+
aria-label="Add todo"
|
|
111
|
+
>
|
|
112
|
+
<Icon name="Plus" size="sm" />
|
|
113
|
+
</button>
|
|
114
|
+
</div>
|
|
115
|
+
</form>
|
|
116
|
+
|
|
117
|
+
<ul className="c-todo__list">
|
|
118
|
+
{filteredItems.length === 0 ? (
|
|
119
|
+
<li className="c-todo__empty">No items to display</li>
|
|
120
|
+
) : (
|
|
121
|
+
filteredItems.map(item => (
|
|
122
|
+
<li key={item.id} className={generateItemClasses(item)}>
|
|
123
|
+
<div className="c-todo__item-content">
|
|
124
|
+
<label className="c-todo__checkbox-label">
|
|
125
|
+
<input
|
|
126
|
+
type="checkbox"
|
|
127
|
+
className="c-todo__checkbox c-checkbox"
|
|
128
|
+
checked={item.completed}
|
|
129
|
+
onChange={() => handleToggle(item.id)}
|
|
130
|
+
disabled={disabled}
|
|
131
|
+
aria-label={`Mark "${item.text}" as ${item.completed ? 'incomplete' : 'complete'}`}
|
|
132
|
+
/>
|
|
133
|
+
<span className="c-todo__item-text">{item.text}</span>
|
|
134
|
+
</label>
|
|
135
|
+
|
|
136
|
+
<button
|
|
137
|
+
type="button"
|
|
138
|
+
className="c-todo__delete-btn c-btn c-btn--error c-btn--sm"
|
|
139
|
+
onClick={() => handleDelete(item.id)}
|
|
140
|
+
disabled={disabled}
|
|
141
|
+
aria-label={`Delete "${item.text}"`}
|
|
142
|
+
>
|
|
143
|
+
<Icon name="Trash" size="sm" />
|
|
144
|
+
</button>
|
|
145
|
+
</div>
|
|
146
|
+
</li>
|
|
147
|
+
))
|
|
148
|
+
)}
|
|
149
|
+
</ul>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
Todo.displayName = 'Todo';
|
|
155
|
+
|
|
156
|
+
export type { TodoProps };
|
|
157
|
+
|
|
158
|
+
export default Todo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Todo';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StoryFn, Meta } from '@storybook/react';
|
|
3
|
+
import { fn } from '@storybook/test';
|
|
4
|
+
import { Toggle } from './Toggle';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Toggle',
|
|
8
|
+
component: Toggle,
|
|
9
|
+
argTypes: {
|
|
10
|
+
initialOn: {
|
|
11
|
+
control: { type: 'boolean' },
|
|
12
|
+
defaultValue: false,
|
|
13
|
+
},
|
|
14
|
+
disabled: {
|
|
15
|
+
control: { type: 'boolean' },
|
|
16
|
+
defaultValue: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
} as Meta<typeof Toggle>;
|
|
20
|
+
|
|
21
|
+
const Template: StoryFn<typeof Toggle> = args => (
|
|
22
|
+
<div style={{ display: 'flex', justifyContent: 'center', padding: '30px' }}>
|
|
23
|
+
<Toggle {...args} />
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const Default = Template.bind({});
|
|
28
|
+
Default.args = {
|
|
29
|
+
initialOn: false,
|
|
30
|
+
disabled: false,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const InitiallyOn = Template.bind({});
|
|
34
|
+
InitiallyOn.args = {
|
|
35
|
+
initialOn: true,
|
|
36
|
+
disabled: false,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Disabled = Template.bind({});
|
|
40
|
+
Disabled.args = {
|
|
41
|
+
initialOn: false,
|
|
42
|
+
disabled: true,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const DisabledOn = Template.bind({});
|
|
46
|
+
DisabledOn.args = {
|
|
47
|
+
initialOn: true,
|
|
48
|
+
disabled: true,
|
|
49
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { TOGGLE } from '../../lib/constants/components';
|
|
3
|
+
|
|
4
|
+
export interface ToggleProps {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the toggle is initially on
|
|
7
|
+
*/
|
|
8
|
+
initialOn?: boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Callback when the toggle is turned on
|
|
12
|
+
*/
|
|
13
|
+
onToggleOn?: () => void;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Callback when the toggle is turned off
|
|
17
|
+
*/
|
|
18
|
+
onToggleOff?: () => void;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Whether the toggle is disabled
|
|
22
|
+
*/
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Additional CSS class for the toggle
|
|
27
|
+
*/
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Toggle component for switching between two states
|
|
33
|
+
*/
|
|
34
|
+
export const Toggle: React.FC<ToggleProps> = ({
|
|
35
|
+
initialOn = false,
|
|
36
|
+
onToggleOn,
|
|
37
|
+
onToggleOff,
|
|
38
|
+
disabled = false,
|
|
39
|
+
className = '',
|
|
40
|
+
}) => {
|
|
41
|
+
const [isOn, setIsOn] = useState(initialOn);
|
|
42
|
+
|
|
43
|
+
// Handle toggle click
|
|
44
|
+
const handleClick = () => {
|
|
45
|
+
if (disabled) return;
|
|
46
|
+
|
|
47
|
+
const newState = !isOn;
|
|
48
|
+
setIsOn(newState);
|
|
49
|
+
|
|
50
|
+
if (newState) {
|
|
51
|
+
if (onToggleOn) onToggleOn();
|
|
52
|
+
} else {
|
|
53
|
+
if (onToggleOff) onToggleOff();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Handle key down events
|
|
58
|
+
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
59
|
+
if (disabled) return;
|
|
60
|
+
|
|
61
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
handleClick();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div
|
|
69
|
+
className={`c-toggle ${isOn ? TOGGLE.CLASSES.IS_ON : ''} ${disabled ? 'is-disabled' : ''} ${className}`}
|
|
70
|
+
onClick={handleClick}
|
|
71
|
+
onKeyDown={handleKeyDown}
|
|
72
|
+
role="switch"
|
|
73
|
+
aria-checked={isOn}
|
|
74
|
+
tabIndex={disabled ? -1 : 0}
|
|
75
|
+
aria-disabled={disabled}
|
|
76
|
+
>
|
|
77
|
+
<div className="c-toggle__switch"></div>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
Toggle.displayName = 'Toggle';
|
|
83
|
+
|
|
84
|
+
export default Toggle;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StoryFn, Meta } from '@storybook/react';
|
|
3
|
+
import { Tooltip } from './Tooltip';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/Tooltip',
|
|
7
|
+
component: Tooltip,
|
|
8
|
+
argTypes: {
|
|
9
|
+
position: {
|
|
10
|
+
control: { type: 'select' },
|
|
11
|
+
options: [
|
|
12
|
+
'top',
|
|
13
|
+
'bottom',
|
|
14
|
+
'left',
|
|
15
|
+
'right',
|
|
16
|
+
'top-left',
|
|
17
|
+
'top-right',
|
|
18
|
+
'bottom-left',
|
|
19
|
+
'bottom-right',
|
|
20
|
+
],
|
|
21
|
+
defaultValue: 'top',
|
|
22
|
+
},
|
|
23
|
+
trigger: {
|
|
24
|
+
control: { type: 'select' },
|
|
25
|
+
options: ['hover', 'click'],
|
|
26
|
+
defaultValue: 'hover',
|
|
27
|
+
},
|
|
28
|
+
delay: {
|
|
29
|
+
control: { type: 'number' },
|
|
30
|
+
defaultValue: 200,
|
|
31
|
+
},
|
|
32
|
+
offset: {
|
|
33
|
+
control: { type: 'number' },
|
|
34
|
+
defaultValue: 10,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
} as Meta<typeof Tooltip>;
|
|
38
|
+
|
|
39
|
+
const Template: StoryFn<typeof Tooltip> = args => (
|
|
40
|
+
<div style={{ display: 'flex', justifyContent: 'center', padding: '100px' }}>
|
|
41
|
+
<Tooltip {...args}>
|
|
42
|
+
<button className="c-btn c-btn--primary">Hover me</button>
|
|
43
|
+
</Tooltip>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const Default = Template.bind({});
|
|
48
|
+
Default.args = {
|
|
49
|
+
content: <p className="u-mb-0">This is a tooltip on top</p>,
|
|
50
|
+
position: 'top',
|
|
51
|
+
trigger: 'hover',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const ClickTrigger = Template.bind({});
|
|
55
|
+
ClickTrigger.args = {
|
|
56
|
+
content: <p className="u-mb-0">Click anywhere to close this tooltip</p>,
|
|
57
|
+
position: 'top',
|
|
58
|
+
trigger: 'click',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const BottomPosition = Template.bind({});
|
|
62
|
+
BottomPosition.args = {
|
|
63
|
+
content: <p className="u-mb-0">This tooltip appears below the trigger</p>,
|
|
64
|
+
position: 'bottom',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const LeftPosition = Template.bind({});
|
|
68
|
+
LeftPosition.args = {
|
|
69
|
+
content: <p className="u-mb-0">This tooltip appears to the left</p>,
|
|
70
|
+
position: 'left',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const RightPosition = Template.bind({});
|
|
74
|
+
RightPosition.args = {
|
|
75
|
+
content: <p className="u-mb-0">This tooltip appears to the right</p>,
|
|
76
|
+
position: 'right',
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const WithIcon = Template.bind({});
|
|
80
|
+
WithIcon.args = {
|
|
81
|
+
content: <p className="u-mb-0">Tooltips work great with icons</p>,
|
|
82
|
+
position: 'top',
|
|
83
|
+
children: <i className="icon-lux-info" style={{ fontSize: '24px', cursor: 'pointer' }}></i>,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const CustomDelay = Template.bind({});
|
|
87
|
+
CustomDelay.args = {
|
|
88
|
+
content: <p className="u-mb-0">This tooltip has a longer delay</p>,
|
|
89
|
+
position: 'top',
|
|
90
|
+
delay: 500,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const CustomOffset = Template.bind({});
|
|
94
|
+
CustomOffset.args = {
|
|
95
|
+
content: <p className="u-mb-0">This tooltip has a larger offset from the trigger</p>,
|
|
96
|
+
position: 'top',
|
|
97
|
+
offset: 20,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const RichContent = Template.bind({});
|
|
101
|
+
RichContent.args = {
|
|
102
|
+
content: (
|
|
103
|
+
<div>
|
|
104
|
+
<h4 style={{ marginTop: 0, marginBottom: '8px' }}>Rich Tooltip Content</h4>
|
|
105
|
+
<ul style={{ margin: 0, paddingLeft: '16px' }}>
|
|
106
|
+
<li>Supports HTML content</li>
|
|
107
|
+
<li>Can include multiple elements</li>
|
|
108
|
+
<li>Helpful for complex information</li>
|
|
109
|
+
</ul>
|
|
110
|
+
</div>
|
|
111
|
+
),
|
|
112
|
+
position: 'bottom',
|
|
113
|
+
trigger: 'click',
|
|
114
|
+
offset: 15,
|
|
115
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React, { ReactNode, useRef, useState } from 'react';
|
|
2
|
+
import { TOOLTIP } from '../../lib/constants/components';
|
|
3
|
+
|
|
4
|
+
export interface TooltipProps {
|
|
5
|
+
/**
|
|
6
|
+
* Content to be displayed in the tooltip
|
|
7
|
+
*/
|
|
8
|
+
content: ReactNode;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The element that will trigger the tooltip
|
|
12
|
+
*/
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The position of the tooltip relative to the trigger
|
|
17
|
+
*/
|
|
18
|
+
position?:
|
|
19
|
+
| 'top'
|
|
20
|
+
| 'bottom'
|
|
21
|
+
| 'left'
|
|
22
|
+
| 'right'
|
|
23
|
+
| 'top-left'
|
|
24
|
+
| 'top-right'
|
|
25
|
+
| 'bottom-left'
|
|
26
|
+
| 'bottom-right';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* How the tooltip is triggered
|
|
30
|
+
*/
|
|
31
|
+
trigger?: 'hover' | 'click';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Additional CSS class for the tooltip
|
|
35
|
+
*/
|
|
36
|
+
className?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Delay before showing the tooltip (in milliseconds)
|
|
40
|
+
*/
|
|
41
|
+
delay?: number;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Offset from the trigger element (in pixels)
|
|
45
|
+
*/
|
|
46
|
+
offset?: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const Tooltip: React.FC<TooltipProps> = ({
|
|
50
|
+
content,
|
|
51
|
+
children,
|
|
52
|
+
position = TOOLTIP.DEFAULTS.POSITION,
|
|
53
|
+
trigger = TOOLTIP.DEFAULTS.TRIGGER,
|
|
54
|
+
className = '',
|
|
55
|
+
delay = TOOLTIP.DEFAULTS.DELAY,
|
|
56
|
+
offset = TOOLTIP.DEFAULTS.OFFSET,
|
|
57
|
+
}) => {
|
|
58
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
59
|
+
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
60
|
+
|
|
61
|
+
const showTooltip = () => {
|
|
62
|
+
if (timeoutRef.current) {
|
|
63
|
+
clearTimeout(timeoutRef.current);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (delay > 0) {
|
|
67
|
+
timeoutRef.current = setTimeout(() => {
|
|
68
|
+
setIsVisible(true);
|
|
69
|
+
}, delay);
|
|
70
|
+
} else {
|
|
71
|
+
setIsVisible(true);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const hideTooltip = () => {
|
|
76
|
+
if (timeoutRef.current) {
|
|
77
|
+
clearTimeout(timeoutRef.current);
|
|
78
|
+
}
|
|
79
|
+
setIsVisible(false);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const toggleTooltip = () => {
|
|
83
|
+
if (isVisible) {
|
|
84
|
+
hideTooltip();
|
|
85
|
+
} else {
|
|
86
|
+
showTooltip();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const getTooltipPositionClasses = () => {
|
|
91
|
+
switch (position) {
|
|
92
|
+
case 'top':
|
|
93
|
+
return 'c-tooltip--top';
|
|
94
|
+
case 'bottom':
|
|
95
|
+
return 'c-tooltip--bottom';
|
|
96
|
+
case 'left':
|
|
97
|
+
return 'c-tooltip--left';
|
|
98
|
+
case 'right':
|
|
99
|
+
return 'c-tooltip--right';
|
|
100
|
+
case 'top-left':
|
|
101
|
+
return 'c-tooltip--top-left';
|
|
102
|
+
case 'top-right':
|
|
103
|
+
return 'c-tooltip--top-right';
|
|
104
|
+
case 'bottom-left':
|
|
105
|
+
return 'c-tooltip--bottom-left';
|
|
106
|
+
case 'bottom-right':
|
|
107
|
+
return 'c-tooltip--bottom-right';
|
|
108
|
+
default:
|
|
109
|
+
return 'c-tooltip--top';
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const triggerProps: React.HTMLAttributes<HTMLDivElement> = {};
|
|
114
|
+
|
|
115
|
+
if (trigger === 'hover') {
|
|
116
|
+
triggerProps.onMouseEnter = showTooltip;
|
|
117
|
+
triggerProps.onMouseLeave = hideTooltip;
|
|
118
|
+
} else if (trigger === 'click') {
|
|
119
|
+
triggerProps.onClick = toggleTooltip;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<div className="u-position-relative u-d-inline-block">
|
|
124
|
+
<div
|
|
125
|
+
className={`${TOOLTIP.SELECTORS.TRIGGER.substring(1)}${className ? ` ${className}` : ''}`}
|
|
126
|
+
{...triggerProps}
|
|
127
|
+
>
|
|
128
|
+
{children}
|
|
129
|
+
</div>
|
|
130
|
+
{isVisible && (
|
|
131
|
+
<div
|
|
132
|
+
className={`c-tooltip ${TOOLTIP.SELECTORS.TOOLTIP.substring(1)} ${getTooltipPositionClasses()}`}
|
|
133
|
+
data-tooltip-position={position}
|
|
134
|
+
data-tooltip-trigger={trigger}
|
|
135
|
+
>
|
|
136
|
+
<div
|
|
137
|
+
className={`c-tooltip__content ${TOOLTIP.SELECTORS.CONTENT.substring(1)} ${isVisible && 'is-active'}`}
|
|
138
|
+
>
|
|
139
|
+
<span className={TOOLTIP.SELECTORS.ARROW.substring(1)}></span>
|
|
140
|
+
{content}
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
Tooltip.displayName = 'Tooltip';
|
|
149
|
+
|
|
150
|
+
export default Tooltip;
|