@shohojdhara/atomix 0.1.30 → 0.2.1
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 +151 -39
- package/dist/atomix.css +13529 -0
- package/dist/atomix.min.css +15 -0
- package/dist/index.d.ts +6112 -1757
- package/dist/index.esm.js +16852 -8364
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16892 -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 +13241 -0
- package/dist/themes/boomdevs.min.css +353 -0
- package/dist/themes/esrar.css +15374 -0
- package/dist/themes/esrar.min.css +189 -0
- package/dist/themes/mashroom.css +28079 -0
- package/dist/themes/mashroom.min.css +403 -0
- package/dist/themes/shaj-default.css +14203 -0
- package/dist/themes/shaj-default.min.css +500 -0
- package/dist/themes/yabai.css +13711 -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/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 +184 -0
- package/src/components/SectionIntro/index.ts +3 -0
- package/src/components/Slider/Slider.stories.tsx +241 -0
- package/src/components/Slider/Slider.tsx +225 -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 +111 -0
- package/src/layouts/Grid/Container.tsx +58 -0
- package/src/layouts/Grid/Grid.stories.tsx +861 -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/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 +339 -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 +1433 -0
- package/src/lib/constants/index.ts +4 -0
- package/src/lib/index.ts +11 -0
- package/src/lib/types/components.ts +4750 -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 +2 -0
- package/src/styles/01-settings/_settings.accordion.scss +7 -5
- package/src/styles/01-settings/_settings.animations.scss +0 -0
- package/src/styles/01-settings/_settings.avatar-group.scss +6 -3
- package/src/styles/01-settings/_settings.avatar.scss +2 -2
- 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 +9 -8
- 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 +12 -10
- package/src/styles/01-settings/_settings.chart.scss +199 -0
- package/src/styles/01-settings/_settings.checkbox-group.scss +0 -0
- package/src/styles/01-settings/_settings.checkbox.scss +0 -0
- 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 +0 -0
- 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 +0 -0
- package/src/styles/01-settings/_settings.edge-panel.scss +0 -0
- package/src/styles/01-settings/_settings.fonts.scss +1 -1
- package/src/styles/01-settings/_settings.form-group.scss +0 -0
- package/src/styles/01-settings/_settings.form.scss +0 -0
- package/src/styles/01-settings/_settings.grid.scss +3 -3
- package/src/styles/01-settings/_settings.hero.scss +1 -1
- package/src/styles/01-settings/_settings.input.scss +1 -1
- package/src/styles/01-settings/_settings.link.scss +0 -0
- package/src/styles/01-settings/_settings.list-group.scss +0 -0
- package/src/styles/01-settings/_settings.list.scss +0 -0
- 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 +0 -0
- package/src/styles/01-settings/_settings.messages.scss +0 -0
- package/src/styles/01-settings/_settings.modal.scss +1 -1
- package/src/styles/01-settings/_settings.nav.scss +0 -0
- package/src/styles/01-settings/_settings.navbar.scss +0 -0
- package/src/styles/01-settings/_settings.pagination.scss +0 -0
- package/src/styles/01-settings/_settings.photoviewer.scss +89 -23
- package/src/styles/01-settings/_settings.popover.scss +0 -0
- 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 +0 -0
- package/src/styles/01-settings/_settings.river.scss +0 -0
- package/src/styles/01-settings/_settings.sectionintro.scss +0 -0
- package/src/styles/01-settings/_settings.select.scss +0 -0
- package/src/styles/01-settings/_settings.side-menu.scss +0 -0
- 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 +11 -3
- package/src/styles/01-settings/_settings.spinner.scss +0 -0
- package/src/styles/01-settings/_settings.steps.scss +1 -1
- package/src/styles/01-settings/_settings.tabs.scss +4 -4
- package/src/styles/01-settings/_settings.testimonials.scss +0 -0
- package/src/styles/01-settings/_settings.todo.scss +0 -0
- package/src/styles/01-settings/_settings.toggle.scss +1 -1
- package/src/styles/01-settings/_settings.tooltip.scss +0 -0
- package/src/styles/01-settings/_settings.typography.scss +2 -0
- package/src/styles/01-settings/_settings.upload.scss +0 -0
- 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.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 +5 -1
- 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 +23 -2
- 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 +5 -1
- 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 +0 -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 +3 -1
- package/src/styles/06-components/_components.avatar-group.scss +0 -0
- package/src/styles/06-components/_components.avatar.scss +0 -0
- package/src/styles/06-components/_components.badge.scss +9 -9
- package/src/styles/06-components/_components.breadcrumb.scss +0 -0
- package/src/styles/06-components/_components.btn-group.scss +0 -0
- package/src/styles/06-components/_components.button.scss +0 -0
- package/src/styles/06-components/_components.callout.scss +2 -1
- package/src/styles/06-components/_components.card.scss +0 -1
- package/src/styles/06-components/_components.chart.scss +2102 -0
- package/src/styles/06-components/_components.checkbox-group.scss +0 -0
- package/src/styles/06-components/_components.checkbox.scss +0 -0
- package/src/styles/06-components/_components.color-mode-toggle.scss +0 -0
- package/src/styles/06-components/_components.countdown.scss +0 -0
- package/src/styles/06-components/_components.data-table.scss +0 -0
- package/src/styles/06-components/_components.datepicker.scss +0 -0
- package/src/styles/06-components/_components.dropdown.scss +0 -0
- package/src/styles/06-components/_components.edge-panel.scss +0 -0
- package/src/styles/06-components/_components.form-group.scss +0 -0
- package/src/styles/06-components/_components.form.scss +0 -0
- package/src/styles/06-components/_components.hero.scss +1 -0
- package/src/styles/06-components/_components.icon.scss +2 -2
- package/src/styles/06-components/_components.image-gallery.scss +0 -0
- package/src/styles/06-components/_components.input.scss +0 -0
- package/src/styles/06-components/_components.list-group.scss +0 -0
- package/src/styles/06-components/_components.list.scss +0 -0
- package/src/styles/06-components/_components.menu.scss +0 -0
- package/src/styles/06-components/_components.messages.scss +0 -0
- package/src/styles/06-components/_components.modal.scss +3 -0
- package/src/styles/06-components/_components.nav.scss +0 -0
- package/src/styles/06-components/_components.navbar.scss +0 -0
- package/src/styles/06-components/_components.pagination.scss +0 -0
- package/src/styles/06-components/_components.photoviewer.scss +603 -545
- package/src/styles/06-components/_components.popover.scss +0 -0
- package/src/styles/06-components/_components.product-review.scss +0 -0
- package/src/styles/06-components/_components.progress.scss +0 -0
- package/src/styles/06-components/_components.rating.scss +0 -0
- package/src/styles/06-components/_components.river.scss +0 -0
- package/src/styles/06-components/_components.sectionintro.scss +0 -0
- package/src/styles/06-components/_components.select.scss +0 -0
- package/src/styles/06-components/_components.side-menu.scss +0 -0
- package/src/styles/06-components/_components.skeleton.scss +0 -0
- package/src/styles/06-components/_components.slider.scss +273 -0
- package/src/styles/06-components/_components.spinner.scss +0 -0
- package/src/styles/06-components/_components.steps.scss +1 -0
- package/src/styles/06-components/_components.tabs.scss +0 -0
- package/src/styles/06-components/_components.testimonials.scss +0 -0
- package/src/styles/06-components/_components.todo.scss +0 -0
- package/src/styles/06-components/_components.toggle.scss +0 -0
- package/src/styles/06-components/_components.tooltip.scss +4 -9
- package/src/styles/06-components/_components.upload.scss +0 -0
- package/src/styles/06-components/_components.video-player.scss +623 -0
- package/src/styles/06-components/_index.scss +3 -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,143 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StoryFn, Meta } from '@storybook/react';
|
|
3
|
+
import { fn } from '@storybook/test';
|
|
4
|
+
import { Popover, PopoverTrigger } from './Popover';
|
|
5
|
+
import { Toggle } from '../Toggle/Toggle';
|
|
6
|
+
import { Button } from '../Button/Button';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Components/Popover',
|
|
10
|
+
component: Popover,
|
|
11
|
+
argTypes: {
|
|
12
|
+
position: {
|
|
13
|
+
control: { type: 'select' },
|
|
14
|
+
options: ['top', 'bottom', 'left', 'right', 'auto'],
|
|
15
|
+
defaultValue: 'top',
|
|
16
|
+
},
|
|
17
|
+
trigger: {
|
|
18
|
+
control: { type: 'select' },
|
|
19
|
+
options: ['click', 'hover'],
|
|
20
|
+
defaultValue: 'click',
|
|
21
|
+
},
|
|
22
|
+
delay: {
|
|
23
|
+
control: { type: 'number' },
|
|
24
|
+
defaultValue: 0,
|
|
25
|
+
},
|
|
26
|
+
offset: {
|
|
27
|
+
control: { type: 'number' },
|
|
28
|
+
defaultValue: 12,
|
|
29
|
+
},
|
|
30
|
+
defaultOpen: {
|
|
31
|
+
control: { type: 'boolean' },
|
|
32
|
+
defaultValue: false,
|
|
33
|
+
},
|
|
34
|
+
closeOnClickOutside: {
|
|
35
|
+
control: { type: 'boolean' },
|
|
36
|
+
defaultValue: true,
|
|
37
|
+
},
|
|
38
|
+
closeOnEscape: {
|
|
39
|
+
control: { type: 'boolean' },
|
|
40
|
+
defaultValue: true,
|
|
41
|
+
},
|
|
42
|
+
className: {
|
|
43
|
+
control: { type: 'text' },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
} as Meta<typeof Popover>;
|
|
47
|
+
|
|
48
|
+
// Default template
|
|
49
|
+
const Template: StoryFn<typeof Popover> = args => {
|
|
50
|
+
const selectOptions = [
|
|
51
|
+
{ value: '1', label: 'Option 1' },
|
|
52
|
+
{ value: '2', label: 'Option 2' },
|
|
53
|
+
{ value: '3', label: 'Option 3' },
|
|
54
|
+
{ value: '4', label: 'Option 4' },
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const [selectedOption, setSelectedOption] = React.useState('1');
|
|
58
|
+
const [showInternalOnly, setShowInternalOnly] = React.useState(false);
|
|
59
|
+
|
|
60
|
+
const handleSelectChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
61
|
+
setSelectedOption(e.target.value);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const handleToggleChange = () => {
|
|
65
|
+
setShowInternalOnly(!showInternalOnly);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const content = (
|
|
69
|
+
<>
|
|
70
|
+
<div className="u-d-flex u-align-items-center u-gap-7">
|
|
71
|
+
<span className="u-text-nowrap">Sort by</span>
|
|
72
|
+
<div className="c-select">
|
|
73
|
+
<select value={selectedOption} onChange={handleSelectChange}>
|
|
74
|
+
{selectOptions.map(option => (
|
|
75
|
+
<option key={option.value} value={option.value}>
|
|
76
|
+
{option.label}
|
|
77
|
+
</option>
|
|
78
|
+
))}
|
|
79
|
+
</select>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
<div className="c-toggle" onClick={handleToggleChange}>
|
|
83
|
+
<div className="c-toggle__label">Show internal comments only</div>
|
|
84
|
+
<div className="c-toggle__switch"></div>
|
|
85
|
+
</div>
|
|
86
|
+
</>
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div
|
|
91
|
+
style={{ padding: '80px', display: 'flex', justifyContent: 'center', background: '#f5f5f5' }}
|
|
92
|
+
>
|
|
93
|
+
<Popover {...args} content={content}>
|
|
94
|
+
<PopoverTrigger trigger={args.trigger}>
|
|
95
|
+
<Button variant="primary" label="Open Popover" />
|
|
96
|
+
</PopoverTrigger>
|
|
97
|
+
</Popover>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const Default = Template.bind({});
|
|
103
|
+
Default.args = {
|
|
104
|
+
position: 'top',
|
|
105
|
+
trigger: 'click',
|
|
106
|
+
offset: 12,
|
|
107
|
+
delay: 0,
|
|
108
|
+
defaultOpen: false,
|
|
109
|
+
closeOnClickOutside: true,
|
|
110
|
+
closeOnEscape: true,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const Hover = Template.bind({});
|
|
114
|
+
Hover.args = {
|
|
115
|
+
...Default.args,
|
|
116
|
+
trigger: 'hover',
|
|
117
|
+
delay: 200,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const BottomPosition = Template.bind({});
|
|
121
|
+
BottomPosition.args = {
|
|
122
|
+
...Default.args,
|
|
123
|
+
position: 'bottom',
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export const LeftPosition = Template.bind({});
|
|
127
|
+
LeftPosition.args = {
|
|
128
|
+
...Default.args,
|
|
129
|
+
position: 'left',
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const RightPosition = Template.bind({});
|
|
133
|
+
RightPosition.args = {
|
|
134
|
+
...Default.args,
|
|
135
|
+
position: 'right',
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const AutoPosition = Template.bind({});
|
|
139
|
+
AutoPosition.args = {
|
|
140
|
+
...Default.args,
|
|
141
|
+
position: 'auto',
|
|
142
|
+
defaultOpen: true, // Open by default to showcase auto-positioning
|
|
143
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import React, { ReactNode, forwardRef, createContext } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { POPOVER } from '../../lib/constants/components';
|
|
4
|
+
import { usePopover } from '../../lib/composables/usePopover';
|
|
5
|
+
import type { PopoverProps, PopoverTriggerProps } from '../../lib/types/components';
|
|
6
|
+
|
|
7
|
+
// Context to share popover state between components
|
|
8
|
+
export const PopoverContext = createContext<{
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
setIsOpen: (isOpen: boolean) => void;
|
|
11
|
+
triggerRef: React.RefObject<HTMLElement | null>;
|
|
12
|
+
popoverId: string;
|
|
13
|
+
triggerType: 'click' | 'hover';
|
|
14
|
+
}>({
|
|
15
|
+
isOpen: false,
|
|
16
|
+
setIsOpen: () => {},
|
|
17
|
+
triggerRef: { current: null },
|
|
18
|
+
popoverId: '',
|
|
19
|
+
triggerType: 'click',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Popover component for displaying floating content
|
|
24
|
+
*/
|
|
25
|
+
export const Popover: React.FC<PopoverProps> = ({
|
|
26
|
+
content,
|
|
27
|
+
position = 'top',
|
|
28
|
+
trigger = 'click',
|
|
29
|
+
className = '',
|
|
30
|
+
delay = 0,
|
|
31
|
+
offset = 12,
|
|
32
|
+
defaultOpen = false,
|
|
33
|
+
isOpen: controlledIsOpen,
|
|
34
|
+
onOpenChange,
|
|
35
|
+
closeOnClickOutside = true,
|
|
36
|
+
closeOnEscape = true,
|
|
37
|
+
id,
|
|
38
|
+
children,
|
|
39
|
+
}) => {
|
|
40
|
+
const {
|
|
41
|
+
isOpen,
|
|
42
|
+
setIsOpen,
|
|
43
|
+
triggerRef,
|
|
44
|
+
popoverRef,
|
|
45
|
+
arrowRef,
|
|
46
|
+
popoverId,
|
|
47
|
+
currentPosition,
|
|
48
|
+
updatePosition,
|
|
49
|
+
} = usePopover({
|
|
50
|
+
position,
|
|
51
|
+
trigger,
|
|
52
|
+
offset,
|
|
53
|
+
delay,
|
|
54
|
+
defaultOpen,
|
|
55
|
+
isOpen: controlledIsOpen,
|
|
56
|
+
onOpenChange,
|
|
57
|
+
closeOnClickOutside,
|
|
58
|
+
closeOnEscape,
|
|
59
|
+
id,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<PopoverContext.Provider
|
|
64
|
+
value={{ isOpen, setIsOpen, triggerRef, popoverId, triggerType: trigger }}
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
|
|
68
|
+
{typeof document !== 'undefined' &&
|
|
69
|
+
createPortal(
|
|
70
|
+
<div
|
|
71
|
+
ref={popoverRef}
|
|
72
|
+
className={`c-popover c-popover--${currentPosition} ${isOpen ? POPOVER.CLASSES.IS_OPEN : ''} ${className}`}
|
|
73
|
+
id={popoverId}
|
|
74
|
+
role="tooltip"
|
|
75
|
+
aria-hidden={!isOpen}
|
|
76
|
+
>
|
|
77
|
+
<div className="c-popover__content">
|
|
78
|
+
<div className="c-popover__content-inner">{content}</div>
|
|
79
|
+
</div>
|
|
80
|
+
<div ref={arrowRef} className="c-popover__arrow"></div>
|
|
81
|
+
</div>,
|
|
82
|
+
document.body
|
|
83
|
+
)}
|
|
84
|
+
</PopoverContext.Provider>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* PopoverTrigger component to wrap the element that triggers the popover
|
|
90
|
+
*/
|
|
91
|
+
export const PopoverTrigger: React.FC<PopoverTriggerProps> = forwardRef<
|
|
92
|
+
HTMLElement,
|
|
93
|
+
PopoverTriggerProps
|
|
94
|
+
>(({ children, trigger: triggerProp }, ref) => {
|
|
95
|
+
const { isOpen, setIsOpen, triggerRef, popoverId, triggerType } =
|
|
96
|
+
React.useContext(PopoverContext);
|
|
97
|
+
|
|
98
|
+
// Determine which trigger type to use - prop from PopoverTrigger or from context
|
|
99
|
+
const effectiveTrigger = triggerProp || triggerType;
|
|
100
|
+
|
|
101
|
+
// Handle trigger events
|
|
102
|
+
const handleClick = () => {
|
|
103
|
+
setIsOpen(!isOpen);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const handleMouseEnter = () => {
|
|
107
|
+
setIsOpen(true);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const handleMouseLeave = () => {
|
|
111
|
+
setIsOpen(false);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// Clone the children element with additional props
|
|
115
|
+
const child = React.Children.only(children) as React.ReactElement;
|
|
116
|
+
|
|
117
|
+
const triggerProps: any = {
|
|
118
|
+
ref: ref || triggerRef,
|
|
119
|
+
'aria-describedby': popoverId,
|
|
120
|
+
'aria-expanded': isOpen,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
if (effectiveTrigger === 'click') {
|
|
124
|
+
triggerProps.onClick = handleClick;
|
|
125
|
+
} else if (effectiveTrigger === 'hover') {
|
|
126
|
+
triggerProps.onMouseEnter = handleMouseEnter;
|
|
127
|
+
triggerProps.onMouseLeave = handleMouseLeave;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return React.cloneElement(child, triggerProps);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
export type { PopoverProps, PopoverTriggerProps };
|
|
134
|
+
|
|
135
|
+
Popover.displayName = 'Popover';
|
|
136
|
+
|
|
137
|
+
export default Popover;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Popover Component
|
|
2
|
+
|
|
3
|
+
The Popover component displays floating content next to a trigger element. It's fully implemented with both React and vanilla JavaScript support, following the Atomix design system standards.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Separate trigger and content components with a context-based system
|
|
8
|
+
- Support for both click and hover interactions
|
|
9
|
+
- Five positioning options (top, bottom, left, right, auto) with intelligent positioning
|
|
10
|
+
- Automatic repositioning based on available space
|
|
11
|
+
- Fully accessible with proper ARIA attributes
|
|
12
|
+
- Both controlled and uncontrolled usage modes
|
|
13
|
+
- Simple API for customization
|
|
14
|
+
- Automatic handling of window resize and scrolling
|
|
15
|
+
- Vanilla JS implementation for non-React projects
|
|
16
|
+
|
|
17
|
+
## React Usage
|
|
18
|
+
|
|
19
|
+
### Basic usage:
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import { Popover, PopoverTrigger } from './components/Popover';
|
|
23
|
+
|
|
24
|
+
<Popover content={<div>Popover content</div>} position="top">
|
|
25
|
+
<PopoverTrigger>
|
|
26
|
+
<button className="c-btn">Open Popover</button>
|
|
27
|
+
</PopoverTrigger>
|
|
28
|
+
</Popover>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Controlled usage:
|
|
32
|
+
|
|
33
|
+
```jsx
|
|
34
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
35
|
+
|
|
36
|
+
<Popover
|
|
37
|
+
content={<div>Controlled popover</div>}
|
|
38
|
+
isOpen={isOpen}
|
|
39
|
+
onOpenChange={setIsOpen}
|
|
40
|
+
>
|
|
41
|
+
<PopoverTrigger>
|
|
42
|
+
<button className="c-btn">Toggle Popover</button>
|
|
43
|
+
</PopoverTrigger>
|
|
44
|
+
</Popover>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Auto-position usage:
|
|
48
|
+
|
|
49
|
+
```jsx
|
|
50
|
+
<Popover
|
|
51
|
+
content={<div>This popover will position itself optimally</div>}
|
|
52
|
+
position="auto"
|
|
53
|
+
>
|
|
54
|
+
<PopoverTrigger>
|
|
55
|
+
<button className="c-btn">Auto-positioning Popover</button>
|
|
56
|
+
</PopoverTrigger>
|
|
57
|
+
</Popover>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Vanilla JavaScript Usage
|
|
61
|
+
|
|
62
|
+
The Popover component can also be used with HTML and vanilla JavaScript:
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<!-- Popover trigger -->
|
|
66
|
+
<button data-popover-id="my-popover" data-popover-trigger="click">
|
|
67
|
+
Open Popover
|
|
68
|
+
</button>
|
|
69
|
+
|
|
70
|
+
<!-- Popover content -->
|
|
71
|
+
<div id="my-popover" class="js-atomix-popover" data-popover-position="auto">
|
|
72
|
+
<div class="c-popover__content">
|
|
73
|
+
<div class="c-popover__content-inner">
|
|
74
|
+
Popover content goes here
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### JavaScript Initialization:
|
|
81
|
+
|
|
82
|
+
The popovers are automatically initialized on page load, but you can also initialize them manually:
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
import { initPopovers } from './components/Popover/scripts';
|
|
86
|
+
|
|
87
|
+
// Initialize all popovers
|
|
88
|
+
initPopovers();
|
|
89
|
+
|
|
90
|
+
// Or create a specific popover instance
|
|
91
|
+
import Popover from './components/Popover/scripts';
|
|
92
|
+
|
|
93
|
+
const element = document.getElementById('my-popover');
|
|
94
|
+
const popover = new Popover(element, {
|
|
95
|
+
position: 'auto',
|
|
96
|
+
trigger: 'click',
|
|
97
|
+
offset: 12,
|
|
98
|
+
delay: 0
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Control programmatically
|
|
102
|
+
popover.open();
|
|
103
|
+
popover.close();
|
|
104
|
+
popover.toggle();
|
|
105
|
+
popover.destroy(); // Clean up event listeners
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Configuration Options
|
|
109
|
+
|
|
110
|
+
| Option | Type | Default | Description |
|
|
111
|
+
|--------|------|---------|-------------|
|
|
112
|
+
| position | 'top', 'bottom', 'left', 'right', 'auto' | 'top' | The position of the popover relative to the trigger |
|
|
113
|
+
| trigger | 'click', 'hover' | 'click' | How the popover is triggered |
|
|
114
|
+
| offset | number | 12 | Offset from the trigger element (in pixels) |
|
|
115
|
+
| delay | number | 0 | Delay before showing the popover (in milliseconds) |
|
|
116
|
+
| defaultOpen | boolean | false | Whether the popover should be open initially (React only) |
|
|
117
|
+
| isOpen | boolean | undefined | Controlled state of the popover (React only) |
|
|
118
|
+
| onOpenChange | function | undefined | Callback when the popover open state changes (React only) |
|
|
119
|
+
| closeOnClickOutside | boolean | true | Whether to close the popover when clicking outside (React only) |
|
|
120
|
+
| closeOnEscape | boolean | true | Whether to close the popover when pressing escape key (React only) |
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StoryFn, Meta } from '@storybook/react';
|
|
3
|
+
import { fn } from '@storybook/test';
|
|
4
|
+
import { ProductReview, ProductReviewProps } from './ProductReview';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/ProductReview',
|
|
8
|
+
component: ProductReview,
|
|
9
|
+
parameters: {
|
|
10
|
+
docs: {
|
|
11
|
+
description: {
|
|
12
|
+
component: 'Product review form for collecting user ratings and feedback',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
argTypes: {
|
|
17
|
+
productName: { control: 'text' },
|
|
18
|
+
productImage: { control: 'text' },
|
|
19
|
+
initialRating: { control: { type: 'number', min: 0, max: 5, step: 0.5 } },
|
|
20
|
+
maxRating: { control: { type: 'number', min: 1, max: 10 } },
|
|
21
|
+
allowHalf: { control: 'boolean' },
|
|
22
|
+
ratingColor: {
|
|
23
|
+
control: {
|
|
24
|
+
type: 'select',
|
|
25
|
+
options: ['primary', 'secondary', 'success', 'info', 'warning', 'error', 'light', 'dark'],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
} as Meta<typeof ProductReview>;
|
|
30
|
+
|
|
31
|
+
const Template: StoryFn<ProductReviewProps> = (args: ProductReviewProps) => (
|
|
32
|
+
<ProductReview {...args} />
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export const Default = Template.bind({});
|
|
36
|
+
Default.args = {
|
|
37
|
+
productName: 'Wireless Headphones',
|
|
38
|
+
productImage: 'https://via.placeholder.com/100',
|
|
39
|
+
initialRating: 0,
|
|
40
|
+
maxRating: 5,
|
|
41
|
+
allowHalf: true,
|
|
42
|
+
ratingColor: 'warning',
|
|
43
|
+
onSubmit: (rating: number, comment: string) => {
|
|
44
|
+
console.log('Rating:', rating);
|
|
45
|
+
console.log('Comment:', comment);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const WithInitialRating = Template.bind({});
|
|
50
|
+
WithInitialRating.args = {
|
|
51
|
+
productName: 'Smart Watch',
|
|
52
|
+
productImage: 'https://via.placeholder.com/100',
|
|
53
|
+
initialRating: 4,
|
|
54
|
+
maxRating: 5,
|
|
55
|
+
allowHalf: true,
|
|
56
|
+
ratingColor: 'warning',
|
|
57
|
+
onSubmit: (rating: number, comment: string) => {
|
|
58
|
+
console.log('Rating:', rating);
|
|
59
|
+
console.log('Comment:', comment);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const WithoutImage = Template.bind({});
|
|
64
|
+
WithoutImage.args = {
|
|
65
|
+
productName: 'Bluetooth Speaker',
|
|
66
|
+
initialRating: 0,
|
|
67
|
+
maxRating: 5,
|
|
68
|
+
allowHalf: true,
|
|
69
|
+
ratingColor: 'warning',
|
|
70
|
+
onSubmit: (rating: number, comment: string) => {
|
|
71
|
+
console.log('Rating:', rating);
|
|
72
|
+
console.log('Comment:', comment);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const CustomRatingScale = Template.bind({});
|
|
77
|
+
CustomRatingScale.args = {
|
|
78
|
+
productName: 'Gaming Laptop',
|
|
79
|
+
productImage: 'https://via.placeholder.com/100',
|
|
80
|
+
initialRating: 0,
|
|
81
|
+
maxRating: 10,
|
|
82
|
+
allowHalf: false,
|
|
83
|
+
ratingColor: 'primary',
|
|
84
|
+
onSubmit: (rating: number, comment: string) => {
|
|
85
|
+
console.log('Rating:', rating);
|
|
86
|
+
console.log('Comment:', comment);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { Rating } from '../Rating/Rating';
|
|
3
|
+
import { Button } from '../Button/Button';
|
|
4
|
+
import type { ThemeColor } from '../../lib/types/components';
|
|
5
|
+
|
|
6
|
+
export interface ProductReviewProps {
|
|
7
|
+
/**
|
|
8
|
+
* Product name
|
|
9
|
+
*/
|
|
10
|
+
productName: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Product image URL
|
|
14
|
+
*/
|
|
15
|
+
productImage?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Initial rating value (0-5)
|
|
19
|
+
*/
|
|
20
|
+
initialRating?: number;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Maximum possible rating value
|
|
24
|
+
*/
|
|
25
|
+
maxRating?: number;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether to allow half-star ratings
|
|
29
|
+
*/
|
|
30
|
+
allowHalf?: boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Color theme for the rating stars
|
|
34
|
+
*/
|
|
35
|
+
ratingColor?: ThemeColor;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Callback when review is submitted
|
|
39
|
+
*/
|
|
40
|
+
onSubmit?: (rating: number, comment: string) => void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Additional CSS class
|
|
44
|
+
*/
|
|
45
|
+
className?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* ProductReview component for collecting user ratings and feedback
|
|
50
|
+
*/
|
|
51
|
+
export const ProductReview: React.FC<ProductReviewProps> = ({
|
|
52
|
+
productName,
|
|
53
|
+
productImage,
|
|
54
|
+
initialRating = 0,
|
|
55
|
+
maxRating = 5,
|
|
56
|
+
allowHalf = true,
|
|
57
|
+
ratingColor = 'warning' as ThemeColor,
|
|
58
|
+
onSubmit,
|
|
59
|
+
className = '',
|
|
60
|
+
}) => {
|
|
61
|
+
const [rating, setRating] = useState<number>(initialRating);
|
|
62
|
+
const [comment, setComment] = useState<string>('');
|
|
63
|
+
const [submitted, setSubmitted] = useState<boolean>(false);
|
|
64
|
+
const reviewRef = useRef<HTMLDivElement>(null);
|
|
65
|
+
const reviewInstance = useRef<any>(null);
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
// Only run on client-side
|
|
69
|
+
if (typeof window === 'undefined' || !reviewRef.current) return undefined;
|
|
70
|
+
|
|
71
|
+
// Cleanup on unmount
|
|
72
|
+
return () => {
|
|
73
|
+
if (reviewInstance.current) {
|
|
74
|
+
reviewInstance.current.destroy();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}, [productName, productImage, initialRating, maxRating, allowHalf, ratingColor, onSubmit]);
|
|
78
|
+
|
|
79
|
+
const handleSubmit = (e: React.FormEvent): void => {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
|
|
82
|
+
if (onSubmit) {
|
|
83
|
+
onSubmit(rating, comment);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
setSubmitted(true);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const containerClasses = ['c-product-review', className].filter(Boolean).join(' ');
|
|
90
|
+
|
|
91
|
+
if (submitted) {
|
|
92
|
+
return (
|
|
93
|
+
<div className={containerClasses} ref={reviewRef}>
|
|
94
|
+
<div className="c-product-review__success">
|
|
95
|
+
<h3>Thank you for your review!</h3>
|
|
96
|
+
<p>Your feedback helps us improve our products.</p>
|
|
97
|
+
<Button
|
|
98
|
+
variant="secondary"
|
|
99
|
+
label="Write another review"
|
|
100
|
+
onClick={() => {
|
|
101
|
+
setSubmitted(false);
|
|
102
|
+
setRating(0);
|
|
103
|
+
setComment('');
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div className={containerClasses} ref={reviewRef}>
|
|
113
|
+
<div className="c-product-review__header">
|
|
114
|
+
<h3 className="c-product-review__title">Review {productName}</h3>
|
|
115
|
+
{productImage && (
|
|
116
|
+
<div className="c-product-review__image-wrapper">
|
|
117
|
+
<img src={productImage} alt={productName} className="c-product-review__image" />
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<form className="c-product-review__form" onSubmit={handleSubmit}>
|
|
123
|
+
<div className="c-product-review__rating-container">
|
|
124
|
+
<label className="c-product-review__label">Your Rating</label>
|
|
125
|
+
<div className="c-rating-container">
|
|
126
|
+
<Rating
|
|
127
|
+
value={rating}
|
|
128
|
+
onChange={setRating}
|
|
129
|
+
allowHalf={allowHalf}
|
|
130
|
+
maxValue={maxRating}
|
|
131
|
+
size="lg"
|
|
132
|
+
color={ratingColor}
|
|
133
|
+
/>
|
|
134
|
+
<span className="c-rating__value">
|
|
135
|
+
{rating > 0 ? rating.toFixed(1) : 'Select a rating'}
|
|
136
|
+
</span>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<div className="c-product-review__comment-container">
|
|
141
|
+
<label htmlFor="review-comment" className="c-product-review__label">
|
|
142
|
+
Your Review
|
|
143
|
+
</label>
|
|
144
|
+
<textarea
|
|
145
|
+
id="review-comment"
|
|
146
|
+
className="c-product-review__textarea"
|
|
147
|
+
value={comment}
|
|
148
|
+
onChange={e => setComment(e.target.value)}
|
|
149
|
+
placeholder="Share your experience with this product..."
|
|
150
|
+
rows={5}
|
|
151
|
+
/>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
<div className="c-product-review__actions">
|
|
155
|
+
<Button
|
|
156
|
+
variant="primary"
|
|
157
|
+
label="Submit Review"
|
|
158
|
+
disabled={rating === 0}
|
|
159
|
+
onClick={() => handleSubmit(new Event('click') as unknown as React.FormEvent)}
|
|
160
|
+
/>
|
|
161
|
+
</div>
|
|
162
|
+
</form>
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
ProductReview.displayName = 'ProductReview';
|
|
168
|
+
|
|
169
|
+
export default ProductReview;
|