@thinkpixellab-public/px-vue 3.0.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/.eslintrc.js +14 -0
- package/.prettierrc.js +10 -0
- package/LICENSE.md +9 -0
- package/README.md +83 -0
- package/assets/feather/activity.svg +1 -0
- package/assets/feather/airplay.svg +1 -0
- package/assets/feather/alert-circle.svg +1 -0
- package/assets/feather/alert-octagon.svg +1 -0
- package/assets/feather/alert-triangle.svg +1 -0
- package/assets/feather/align-center.svg +1 -0
- package/assets/feather/align-justify.svg +1 -0
- package/assets/feather/align-left.svg +1 -0
- package/assets/feather/align-right.svg +1 -0
- package/assets/feather/anchor.svg +1 -0
- package/assets/feather/aperture.svg +1 -0
- package/assets/feather/archive.svg +1 -0
- package/assets/feather/arrow-down-circle.svg +1 -0
- package/assets/feather/arrow-down-left.svg +1 -0
- package/assets/feather/arrow-down-right.svg +1 -0
- package/assets/feather/arrow-down.svg +1 -0
- package/assets/feather/arrow-left-circle.svg +1 -0
- package/assets/feather/arrow-left.svg +1 -0
- package/assets/feather/arrow-right-circle.svg +1 -0
- package/assets/feather/arrow-right.svg +1 -0
- package/assets/feather/arrow-up-circle.svg +1 -0
- package/assets/feather/arrow-up-left.svg +1 -0
- package/assets/feather/arrow-up-right.svg +1 -0
- package/assets/feather/arrow-up.svg +1 -0
- package/assets/feather/at-sign.svg +1 -0
- package/assets/feather/award.svg +1 -0
- package/assets/feather/bar-chart-2.svg +1 -0
- package/assets/feather/bar-chart.svg +1 -0
- package/assets/feather/battery-charging.svg +1 -0
- package/assets/feather/battery.svg +1 -0
- package/assets/feather/bell-off.svg +1 -0
- package/assets/feather/bell.svg +1 -0
- package/assets/feather/bluetooth.svg +1 -0
- package/assets/feather/bold.svg +1 -0
- package/assets/feather/book-open.svg +1 -0
- package/assets/feather/book.svg +1 -0
- package/assets/feather/bookmark.svg +1 -0
- package/assets/feather/box.svg +1 -0
- package/assets/feather/briefcase.svg +1 -0
- package/assets/feather/calendar.svg +1 -0
- package/assets/feather/camera-off.svg +1 -0
- package/assets/feather/camera.svg +1 -0
- package/assets/feather/cast.svg +1 -0
- package/assets/feather/check-circle.svg +1 -0
- package/assets/feather/check-square.svg +1 -0
- package/assets/feather/check.svg +1 -0
- package/assets/feather/chevron-down.svg +1 -0
- package/assets/feather/chevron-left.svg +1 -0
- package/assets/feather/chevron-right.svg +1 -0
- package/assets/feather/chevron-up.svg +1 -0
- package/assets/feather/chevrons-down.svg +1 -0
- package/assets/feather/chevrons-left.svg +1 -0
- package/assets/feather/chevrons-right.svg +1 -0
- package/assets/feather/chevrons-up.svg +1 -0
- package/assets/feather/chrome.svg +1 -0
- package/assets/feather/circle.svg +1 -0
- package/assets/feather/clipboard.svg +1 -0
- package/assets/feather/clock.svg +1 -0
- package/assets/feather/cloud-drizzle.svg +1 -0
- package/assets/feather/cloud-lightning.svg +1 -0
- package/assets/feather/cloud-off.svg +1 -0
- package/assets/feather/cloud-rain.svg +1 -0
- package/assets/feather/cloud-snow.svg +1 -0
- package/assets/feather/cloud.svg +1 -0
- package/assets/feather/code.svg +1 -0
- package/assets/feather/codepen.svg +1 -0
- package/assets/feather/codesandbox.svg +1 -0
- package/assets/feather/coffee.svg +1 -0
- package/assets/feather/columns.svg +1 -0
- package/assets/feather/command.svg +1 -0
- package/assets/feather/compass.svg +1 -0
- package/assets/feather/copy.svg +1 -0
- package/assets/feather/corner-down-left.svg +1 -0
- package/assets/feather/corner-down-right.svg +1 -0
- package/assets/feather/corner-left-down.svg +1 -0
- package/assets/feather/corner-left-up.svg +1 -0
- package/assets/feather/corner-right-down.svg +1 -0
- package/assets/feather/corner-right-up.svg +1 -0
- package/assets/feather/corner-up-left.svg +1 -0
- package/assets/feather/corner-up-right.svg +1 -0
- package/assets/feather/cpu.svg +1 -0
- package/assets/feather/credit-card.svg +1 -0
- package/assets/feather/crop.svg +1 -0
- package/assets/feather/crosshair.svg +1 -0
- package/assets/feather/database.svg +1 -0
- package/assets/feather/delete.svg +1 -0
- package/assets/feather/disc.svg +1 -0
- package/assets/feather/divide-circle.svg +1 -0
- package/assets/feather/divide-square.svg +1 -0
- package/assets/feather/divide.svg +1 -0
- package/assets/feather/dollar-sign.svg +1 -0
- package/assets/feather/download-cloud.svg +1 -0
- package/assets/feather/download.svg +1 -0
- package/assets/feather/dribbble.svg +1 -0
- package/assets/feather/droplet.svg +1 -0
- package/assets/feather/edit-2.svg +1 -0
- package/assets/feather/edit-3.svg +1 -0
- package/assets/feather/edit.svg +1 -0
- package/assets/feather/external-link.svg +1 -0
- package/assets/feather/eye-off.svg +1 -0
- package/assets/feather/eye.svg +1 -0
- package/assets/feather/facebook.svg +1 -0
- package/assets/feather/fast-forward.svg +1 -0
- package/assets/feather/feather.svg +1 -0
- package/assets/feather/figma.svg +1 -0
- package/assets/feather/file-minus.svg +1 -0
- package/assets/feather/file-plus.svg +1 -0
- package/assets/feather/file-text.svg +1 -0
- package/assets/feather/file.svg +1 -0
- package/assets/feather/film.svg +1 -0
- package/assets/feather/filter.svg +1 -0
- package/assets/feather/flag.svg +1 -0
- package/assets/feather/folder-minus.svg +1 -0
- package/assets/feather/folder-plus.svg +1 -0
- package/assets/feather/folder.svg +1 -0
- package/assets/feather/framer.svg +1 -0
- package/assets/feather/frown.svg +1 -0
- package/assets/feather/gift.svg +1 -0
- package/assets/feather/git-branch.svg +1 -0
- package/assets/feather/git-commit.svg +1 -0
- package/assets/feather/git-merge.svg +1 -0
- package/assets/feather/git-pull-request.svg +1 -0
- package/assets/feather/github.svg +1 -0
- package/assets/feather/gitlab.svg +1 -0
- package/assets/feather/globe.svg +1 -0
- package/assets/feather/grid.svg +1 -0
- package/assets/feather/hard-drive.svg +1 -0
- package/assets/feather/hash.svg +1 -0
- package/assets/feather/headphones.svg +1 -0
- package/assets/feather/heart.svg +1 -0
- package/assets/feather/help-circle.svg +1 -0
- package/assets/feather/hexagon.svg +1 -0
- package/assets/feather/home.svg +1 -0
- package/assets/feather/image.svg +1 -0
- package/assets/feather/inbox.svg +1 -0
- package/assets/feather/info.svg +1 -0
- package/assets/feather/instagram.svg +1 -0
- package/assets/feather/italic.svg +1 -0
- package/assets/feather/key.svg +1 -0
- package/assets/feather/layers.svg +1 -0
- package/assets/feather/layout.svg +1 -0
- package/assets/feather/life-buoy.svg +1 -0
- package/assets/feather/link-2.svg +1 -0
- package/assets/feather/link.svg +1 -0
- package/assets/feather/linkedin.svg +1 -0
- package/assets/feather/list.svg +1 -0
- package/assets/feather/loader.svg +1 -0
- package/assets/feather/lock.svg +1 -0
- package/assets/feather/log-in.svg +1 -0
- package/assets/feather/log-out.svg +1 -0
- package/assets/feather/mail.svg +1 -0
- package/assets/feather/map-pin.svg +1 -0
- package/assets/feather/map.svg +1 -0
- package/assets/feather/maximize-2.svg +1 -0
- package/assets/feather/maximize.svg +1 -0
- package/assets/feather/meh.svg +1 -0
- package/assets/feather/menu.svg +1 -0
- package/assets/feather/message-circle.svg +1 -0
- package/assets/feather/message-square.svg +1 -0
- package/assets/feather/mic-off.svg +1 -0
- package/assets/feather/mic.svg +1 -0
- package/assets/feather/minimize-2.svg +1 -0
- package/assets/feather/minimize.svg +1 -0
- package/assets/feather/minus-circle.svg +1 -0
- package/assets/feather/minus-square.svg +1 -0
- package/assets/feather/minus.svg +1 -0
- package/assets/feather/monitor.svg +1 -0
- package/assets/feather/moon.svg +1 -0
- package/assets/feather/more-horizontal.svg +1 -0
- package/assets/feather/more-vertical.svg +1 -0
- package/assets/feather/mouse-pointer.svg +1 -0
- package/assets/feather/move.svg +1 -0
- package/assets/feather/music.svg +1 -0
- package/assets/feather/navigation-2.svg +1 -0
- package/assets/feather/navigation.svg +1 -0
- package/assets/feather/octagon.svg +1 -0
- package/assets/feather/package.svg +1 -0
- package/assets/feather/paperclip.svg +1 -0
- package/assets/feather/pause-circle.svg +1 -0
- package/assets/feather/pause.svg +1 -0
- package/assets/feather/pen-tool.svg +1 -0
- package/assets/feather/percent.svg +1 -0
- package/assets/feather/phone-call.svg +1 -0
- package/assets/feather/phone-forwarded.svg +1 -0
- package/assets/feather/phone-incoming.svg +1 -0
- package/assets/feather/phone-missed.svg +1 -0
- package/assets/feather/phone-off.svg +1 -0
- package/assets/feather/phone-outgoing.svg +1 -0
- package/assets/feather/phone.svg +1 -0
- package/assets/feather/pie-chart.svg +1 -0
- package/assets/feather/play-circle.svg +1 -0
- package/assets/feather/play.svg +1 -0
- package/assets/feather/plus-circle.svg +1 -0
- package/assets/feather/plus-square.svg +1 -0
- package/assets/feather/plus.svg +1 -0
- package/assets/feather/pocket.svg +1 -0
- package/assets/feather/power.svg +1 -0
- package/assets/feather/printer.svg +1 -0
- package/assets/feather/radio.svg +1 -0
- package/assets/feather/refresh-ccw.svg +1 -0
- package/assets/feather/refresh-cw.svg +1 -0
- package/assets/feather/repeat.svg +1 -0
- package/assets/feather/rewind.svg +1 -0
- package/assets/feather/rotate-ccw.svg +1 -0
- package/assets/feather/rotate-cw.svg +1 -0
- package/assets/feather/rss.svg +1 -0
- package/assets/feather/save.svg +1 -0
- package/assets/feather/scissors.svg +1 -0
- package/assets/feather/search.svg +1 -0
- package/assets/feather/send.svg +1 -0
- package/assets/feather/server.svg +1 -0
- package/assets/feather/settings.svg +1 -0
- package/assets/feather/share-2.svg +1 -0
- package/assets/feather/share.svg +1 -0
- package/assets/feather/shield-off.svg +1 -0
- package/assets/feather/shield.svg +1 -0
- package/assets/feather/shopping-bag.svg +1 -0
- package/assets/feather/shopping-cart.svg +1 -0
- package/assets/feather/shuffle.svg +1 -0
- package/assets/feather/sidebar.svg +1 -0
- package/assets/feather/skip-back.svg +1 -0
- package/assets/feather/skip-forward.svg +1 -0
- package/assets/feather/slack.svg +1 -0
- package/assets/feather/slash.svg +1 -0
- package/assets/feather/sliders.svg +1 -0
- package/assets/feather/smartphone.svg +1 -0
- package/assets/feather/smile.svg +1 -0
- package/assets/feather/speaker.svg +1 -0
- package/assets/feather/square.svg +1 -0
- package/assets/feather/star.svg +1 -0
- package/assets/feather/stop-circle.svg +1 -0
- package/assets/feather/sun.svg +1 -0
- package/assets/feather/sunrise.svg +1 -0
- package/assets/feather/sunset.svg +1 -0
- package/assets/feather/table.svg +1 -0
- package/assets/feather/tablet.svg +1 -0
- package/assets/feather/tag.svg +1 -0
- package/assets/feather/target.svg +1 -0
- package/assets/feather/terminal.svg +1 -0
- package/assets/feather/thermometer.svg +1 -0
- package/assets/feather/thumbs-down.svg +1 -0
- package/assets/feather/thumbs-up.svg +1 -0
- package/assets/feather/toggle-left.svg +1 -0
- package/assets/feather/toggle-right.svg +1 -0
- package/assets/feather/tool.svg +1 -0
- package/assets/feather/trash-2.svg +1 -0
- package/assets/feather/trash.svg +1 -0
- package/assets/feather/trello.svg +1 -0
- package/assets/feather/trending-down.svg +1 -0
- package/assets/feather/trending-up.svg +1 -0
- package/assets/feather/triangle.svg +1 -0
- package/assets/feather/truck.svg +1 -0
- package/assets/feather/tv.svg +1 -0
- package/assets/feather/twitch.svg +1 -0
- package/assets/feather/twitter.svg +1 -0
- package/assets/feather/type.svg +1 -0
- package/assets/feather/umbrella.svg +1 -0
- package/assets/feather/underline.svg +1 -0
- package/assets/feather/unlock.svg +1 -0
- package/assets/feather/upload-cloud.svg +1 -0
- package/assets/feather/upload.svg +1 -0
- package/assets/feather/user-check.svg +1 -0
- package/assets/feather/user-minus.svg +1 -0
- package/assets/feather/user-plus.svg +1 -0
- package/assets/feather/user-x.svg +1 -0
- package/assets/feather/user.svg +1 -0
- package/assets/feather/users.svg +1 -0
- package/assets/feather/video-off.svg +1 -0
- package/assets/feather/video.svg +1 -0
- package/assets/feather/voicemail.svg +1 -0
- package/assets/feather/volume-1.svg +1 -0
- package/assets/feather/volume-2.svg +1 -0
- package/assets/feather/volume-x.svg +1 -0
- package/assets/feather/volume.svg +1 -0
- package/assets/feather/watch.svg +1 -0
- package/assets/feather/wifi-off.svg +1 -0
- package/assets/feather/wifi.svg +1 -0
- package/assets/feather/wind.svg +1 -0
- package/assets/feather/x-circle.svg +1 -0
- package/assets/feather/x-octagon.svg +1 -0
- package/assets/feather/x-square.svg +1 -0
- package/assets/feather/x.svg +1 -0
- package/assets/feather/youtube.svg +1 -0
- package/assets/feather/zap-off.svg +1 -0
- package/assets/feather/zap.svg +1 -0
- package/assets/feather/zoom-in.svg +1 -0
- package/assets/feather/zoom-out.svg +1 -0
- package/assets/icons/calendar.svg +6 -0
- package/assets/icons/check.svg +1 -0
- package/assets/icons/close-sm.svg +1 -0
- package/assets/icons/close.svg +1 -0
- package/assets/icons/copy.svg +1 -0
- package/assets/icons/dropdown.svg +8 -0
- package/assets/icons/invalid.svg +1 -0
- package/assets/icons/menu.svg +1 -0
- package/assets/icons/nav-next.svg +1 -0
- package/assets/icons/nav-prev.svg +1 -0
- package/assets/icons/sort-asc.svg +1 -0
- package/assets/icons/sort-desc.svg +1 -0
- package/assets/test/README.md +1 -0
- package/assets/test/trash.svg +8 -0
- package/babel.config.js +16 -0
- package/components/PxAspect.vue +127 -0
- package/components/PxAutoClamp.vue +75 -0
- package/components/PxBalancedText.vue +118 -0
- package/components/PxBase.vue +15 -0
- package/components/PxBaseDate.vue +27 -0
- package/components/PxBaseItems.vue +72 -0
- package/components/PxBaseItemsSelect.vue +230 -0
- package/components/PxBaseResize.vue +60 -0
- package/components/PxBaseToggle.vue +56 -0
- package/components/PxBaseVariants.vue +62 -0
- package/components/PxBaseVisible.vue +40 -0
- package/components/PxCalendar.vue +385 -0
- package/components/PxCard.vue +47 -0
- package/components/PxCardGrid.vue +386 -0
- package/components/PxClock.vue +510 -0
- package/components/PxCopyText.vue +78 -0
- package/components/PxDatePicker.vue +249 -0
- package/components/PxDropdown.vue +181 -0
- package/components/PxExpander.vue +46 -0
- package/components/PxFeatherIcon.vue +29 -0
- package/components/PxFeatherIconButton.vue +19 -0
- package/components/PxFit.vue +274 -0
- package/components/PxFlex.vue +93 -0
- package/components/PxFloat.vue +32 -0
- package/components/PxIcon.vue +43 -0
- package/components/PxIconButton.vue +115 -0
- package/components/PxIdUniquer.vue +59 -0
- package/components/PxModal.vue +365 -0
- package/components/PxNineGrid.vue +94 -0
- package/components/PxPivot.vue +207 -0
- package/components/PxPopup.vue +230 -0
- package/components/PxPortal.vue +138 -0
- package/components/PxPortalTarget.vue +25 -0
- package/components/PxProgressCircle.vue +73 -0
- package/components/PxRadioButton.vue +83 -0
- package/components/PxSideDrawer.vue +164 -0
- package/components/PxSlideTransition.vue +116 -0
- package/components/PxSlides.vue +217 -0
- package/components/PxStylesPreview.vue +129 -0
- package/components/PxSvg.vue +157 -0
- package/components/PxSwiper.vue +271 -0
- package/components/PxSwiperSlide.vue +42 -0
- package/components/PxSyncHeight.vue +137 -0
- package/components/PxTable.vue +323 -0
- package/components/PxTabs.vue +1 -0
- package/components/PxTextbox.vue +90 -0
- package/components/PxToggle.vue +125 -0
- package/components/PxToggleButton.vue +139 -0
- package/components/PxToggleButtonList.vue +131 -0
- package/components/PxTransitionExpand.vue +100 -0
- package/components/PxValidator.vue +431 -0
- package/components/PxVueTest.vue +761 -0
- package/components/README.md +0 -0
- package/dev/data/fruits.js +59 -0
- package/dev/data/random.js +13 -0
- package/dev/demos/Demo-PxBaseDrag.vue +94 -0
- package/dev/demos/Demo-PxCardGrid.vue +53 -0
- package/dev/demos/Demo-PxPivot.vue +58 -0
- package/dev/demos/Demo-PxSideDrawer.vue +72 -0
- package/dev/demos/Demo-PxSlideTransition.vue +86 -0
- package/dev/demos/Demo-PxSlides.vue +142 -0
- package/dev/demos/Demo-PxStylesPreview.vue +46 -0
- package/dev/demos/Demo-PxSwiper.vue +44 -0
- package/dev/demos/DemoPicker.vue +79 -0
- package/dev/dev.vue +56 -0
- package/dev/serve.js +17 -0
- package/package.json +45 -0
- package/plugins/common-client.js +13 -0
- package/plugins/common-lib.js +4 -0
- package/plugins/common.js +39 -0
- package/plugins/filters/aspect.js +14 -0
- package/plugins/filters/date.js +26 -0
- package/plugins/filters/kebab.js +9 -0
- package/plugins/filters/phone.js +7 -0
- package/plugins/filters/slug.js +26 -0
- package/plugins/filters/spacenator.js +11 -0
- package/plugins/filters/stringToItems.js +28 -0
- package/plugins/filters/striphtml.js +10 -0
- package/plugins/mixins/eventBus.js +23 -0
- package/px-styles.config.scss +12 -0
- package/styles/helpers.scss +14 -0
- package/styles/px.scss +6 -0
- package/utils/balanceText.js +123 -0
- package/utils/bem.js +99 -0
- package/utils/cardGrid.js +383 -0
- package/utils/cssStr.js +45 -0
- package/utils/drag.js +363 -0
- package/utils/fit.js +73 -0
- package/utils/tween.js +129 -0
- package/utils/utils.js +167 -0
- package/utils/variants.js +33 -0
- package/vue.config.js +12 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
The grid will be created to contain cells (like a spreadsheet). A space represents an area that
|
|
4
|
+
spans a certain number of cells and can contain a certain number of cards. Keeping all of this
|
|
5
|
+
straight can get a little confusing because the terms are highly related but different, so here
|
|
6
|
+
is the breakdown in some detail:
|
|
7
|
+
|
|
8
|
+
## Cell
|
|
9
|
+
A single unit in the grid that spans 1 row and 1 column.
|
|
10
|
+
|
|
11
|
+
## Space
|
|
12
|
+
An area that spans a certain number of cells and contains a certain number of cards. As implemented
|
|
13
|
+
spaces can only span columns (not rows). We support three kinds of spaces:
|
|
14
|
+
|
|
15
|
+
- **default** space ('--') This is a normal looking card. It contains 1 card and is 1x1.
|
|
16
|
+
- **stacked** space ('==') This space is also (1x1) but contains two cards stacked vertically.
|
|
17
|
+
- **wide** space ('-----') This space is 2x1 cells and contains one card.
|
|
18
|
+
|
|
19
|
+
## Card
|
|
20
|
+
Cards are areas within a space. Default and wide spaces contain a single card. Stacked spaces
|
|
21
|
+
contain two cards.
|
|
22
|
+
|
|
23
|
+
## Space Notation
|
|
24
|
+
In order to simplify the definition of spaces, they can be represented with the notation above and
|
|
25
|
+
converted to and from objects with the functions below.
|
|
26
|
+
|
|
27
|
+
## Templates
|
|
28
|
+
|
|
29
|
+
You can define a template using space notation like this:
|
|
30
|
+
|
|
31
|
+
'== -- -----',
|
|
32
|
+
'-- == -- --',
|
|
33
|
+
'----- -- ==',
|
|
34
|
+
'-- -- == --',
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Basic Example
|
|
38
|
+
|
|
39
|
+
<px-card-grid
|
|
40
|
+
:items="fruits"
|
|
41
|
+
:gap="30"
|
|
42
|
+
:maxColumns="4"
|
|
43
|
+
:debug="true",
|
|
44
|
+
:templates="{
|
|
45
|
+
4: ['== -- -----', '-- == -- --', '----- -- ==', '-- -- == --'],
|
|
46
|
+
3: ['== -- --', '-- -- ==', '-- == --'],
|
|
47
|
+
2: ['-- --', '-----', '== --'],
|
|
48
|
+
}"
|
|
49
|
+
>
|
|
50
|
+
<template #default="{ item }">{{ item.name }}</template>
|
|
51
|
+
</px-card-grid>
|
|
52
|
+
|
|
53
|
+
-->
|
|
54
|
+
|
|
55
|
+
<template>
|
|
56
|
+
<div :class="bem({ debug: debug })">
|
|
57
|
+
<div :class="bem('grid', { cols: String(columnCount) })" :style="gridStyle">
|
|
58
|
+
<div :class="bem('row')" v-for="(row, rowIndex) in rows" :key="rowIndex">
|
|
59
|
+
<div
|
|
60
|
+
:class="bem('space', { layout: space.name })"
|
|
61
|
+
v-for="(space, spaceIndex) in row"
|
|
62
|
+
:key="spaceIndex"
|
|
63
|
+
>
|
|
64
|
+
<div
|
|
65
|
+
:class="bem('card')"
|
|
66
|
+
v-for="(item, cardIndex) in space.cards"
|
|
67
|
+
:key="cardIndex"
|
|
68
|
+
>
|
|
69
|
+
<slot
|
|
70
|
+
name="default"
|
|
71
|
+
:index="items.indexOf(item)"
|
|
72
|
+
:item="item || {}"
|
|
73
|
+
:size="space.name"
|
|
74
|
+
>
|
|
75
|
+
{{ items.indexOf(item) }}:{{ space.name }}
|
|
76
|
+
</slot>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
|
+
<script>
|
|
85
|
+
import aspect from '../plugins/filters/aspect.js';
|
|
86
|
+
import PxBaseItems from './PxBaseItems.vue';
|
|
87
|
+
|
|
88
|
+
// prettier-ignore
|
|
89
|
+
const defaultTemplates = {
|
|
90
|
+
5: [
|
|
91
|
+
'== -- == -- ==',
|
|
92
|
+
'-- == -- == --'
|
|
93
|
+
],
|
|
94
|
+
4:[
|
|
95
|
+
'== -- -----',
|
|
96
|
+
'-- == -- --',
|
|
97
|
+
'----- -- ==',
|
|
98
|
+
'-- -- == --',
|
|
99
|
+
],
|
|
100
|
+
3: [
|
|
101
|
+
'== -- --',
|
|
102
|
+
'-- -- ==',
|
|
103
|
+
'-- == --',
|
|
104
|
+
],
|
|
105
|
+
2: [
|
|
106
|
+
'-- --',
|
|
107
|
+
'-- ==',
|
|
108
|
+
'== --',
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// prettier-ignore
|
|
114
|
+
const spaces = [
|
|
115
|
+
{ name: 'default', notation: '--', cards: 1, colspan: 1, },
|
|
116
|
+
{ name: 'wide', notation: '-----', cards: 1, colspan: 2, },
|
|
117
|
+
{ name: 'stacked', notation: '==', cards: 2, colspan: 1 },
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
const spaceNotationToObject = symbol => {
|
|
121
|
+
return spaces.find(s => s.notation == symbol);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// converts a template in space notation into an array of rows containing space objects
|
|
125
|
+
const spaceTemplateToSpaceRows = rows => {
|
|
126
|
+
let spaces = [];
|
|
127
|
+
rows.forEach(row => {
|
|
128
|
+
row = row.trim().split(/[\s\r\n]+/);
|
|
129
|
+
spaces.push(row.map(symbol => spaceNotationToObject(symbol)));
|
|
130
|
+
});
|
|
131
|
+
return spaces;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export default {
|
|
135
|
+
name: 'px-card-grid',
|
|
136
|
+
// components: { Component },
|
|
137
|
+
mixins: [PxBaseItems],
|
|
138
|
+
props: {
|
|
139
|
+
templates: { type: Object, default: () => defaultTemplates },
|
|
140
|
+
maxColumns: { type: Number, default: 6 },
|
|
141
|
+
maxRows: { type: Number, default: null },
|
|
142
|
+
allowOrphans: { type: Boolean, default: true },
|
|
143
|
+
padOrphans: { type: Boolean, default: false },
|
|
144
|
+
cardMinWidth: { type: Number, default: 240 },
|
|
145
|
+
cardMaxWidth: { type: Number, default: 320 },
|
|
146
|
+
cardAspect: { default: 3 / 4 },
|
|
147
|
+
gap: { type: Number, default: 24 },
|
|
148
|
+
debug: { type: Boolean, default: false },
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
data() {
|
|
152
|
+
return {
|
|
153
|
+
columnCount: 0,
|
|
154
|
+
rowTemplates: null,
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
computed: {
|
|
158
|
+
gridStyle() {
|
|
159
|
+
const defAspect = aspect(this.cardAspect);
|
|
160
|
+
const wideAspect = (this.cardMinWidth * 2 + this.gap) / (this.cardMinWidth / defAspect);
|
|
161
|
+
const maxGridWidth =
|
|
162
|
+
this.cardMaxWidth * this.columnCount + this.gap * (this.columnCount - 1);
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
// prettier-ignore
|
|
166
|
+
gridTemplateColumns: `repeat(${this.columnCount}, 1fr)`,
|
|
167
|
+
maxWidth: this.cssPx(maxGridWidth),
|
|
168
|
+
'--gap': this.cssPx(this.gap),
|
|
169
|
+
'--aspect': defAspect,
|
|
170
|
+
'--aspect-wide': wideAspect,
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
rows() {
|
|
175
|
+
// Returns an array of rows, each of which contains an array of spaces each
|
|
176
|
+
// of which contains 1 or more items that can be used to create cards.
|
|
177
|
+
|
|
178
|
+
if (!this.rowTemplates || !this.items || !this.items.length || this.columnCount == 0) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// get relevant row templates based on the number of columns
|
|
183
|
+
let templates = this.rowTemplates[this.columnCount];
|
|
184
|
+
|
|
185
|
+
if (!templates) {
|
|
186
|
+
console.error(`Could not create grid for ${this.columnCount} columns.`);
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let rows = [];
|
|
191
|
+
let rowIndex = 0;
|
|
192
|
+
let itemIndex = 0;
|
|
193
|
+
|
|
194
|
+
while (itemIndex < this.items.length) {
|
|
195
|
+
let template = templates[rowIndex % templates.length];
|
|
196
|
+
|
|
197
|
+
let row = template.map(spaceTemplate => {
|
|
198
|
+
let cards = Array(spaceTemplate.cards).fill(0);
|
|
199
|
+
|
|
200
|
+
cards = cards.map(() => {
|
|
201
|
+
const item = this.getItemForSpace(itemIndex);
|
|
202
|
+
itemIndex++;
|
|
203
|
+
return item;
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
name: spaceTemplate.name,
|
|
208
|
+
cardCount: spaceTemplate.cards,
|
|
209
|
+
cards: cards,
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
rows.push(row);
|
|
213
|
+
rowIndex++;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
let hasOrphans = itemIndex > this.items.length;
|
|
217
|
+
|
|
218
|
+
if (hasOrphans && !this.allowOrphans) {
|
|
219
|
+
rows.pop();
|
|
220
|
+
} else {
|
|
221
|
+
if (!this.padOrphans) {
|
|
222
|
+
rows[rows.length - 1] = rows[rows.length - 1].filter(sp => {
|
|
223
|
+
sp.cards = sp.cards.filter(card => !!card);
|
|
224
|
+
return sp.cards.length;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return rows;
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
watch: {
|
|
233
|
+
templates() {
|
|
234
|
+
this.updateRowTemplates();
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
mounted() {
|
|
238
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
239
|
+
this.resize();
|
|
240
|
+
});
|
|
241
|
+
this.resizeObserver.observe(this.$el);
|
|
242
|
+
|
|
243
|
+
this.resize();
|
|
244
|
+
this.updateRowTemplates();
|
|
245
|
+
},
|
|
246
|
+
beforeDestroy() {
|
|
247
|
+
this.resizeObserver.disconnect();
|
|
248
|
+
delete this.resizeObserver;
|
|
249
|
+
},
|
|
250
|
+
methods: {
|
|
251
|
+
getItemForSpace(index) {
|
|
252
|
+
if (this.items && index < this.items.length) {
|
|
253
|
+
return this.items[index];
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (index > 100) {
|
|
257
|
+
debugger;
|
|
258
|
+
}
|
|
259
|
+
return null;
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
updateRowTemplates() {
|
|
263
|
+
// get a single card (needed to fill missing templates)
|
|
264
|
+
const single = spaceNotationToObject('--');
|
|
265
|
+
|
|
266
|
+
let rowTemplates = {};
|
|
267
|
+
|
|
268
|
+
for (let i = this.maxColumns; i > 0; i--) {
|
|
269
|
+
// if we have a template for this count, parse it and use it
|
|
270
|
+
if (i in this.templates) {
|
|
271
|
+
rowTemplates[i] = spaceTemplateToSpaceRows(this.templates[i]);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// otherwise create one with all singles
|
|
275
|
+
else {
|
|
276
|
+
rowTemplates[i] = [Array(i).fill(single)];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
this.rowTemplates = rowTemplates;
|
|
281
|
+
},
|
|
282
|
+
resize() {
|
|
283
|
+
let count = 1;
|
|
284
|
+
let availableWidth = this.$el.offsetWidth;
|
|
285
|
+
|
|
286
|
+
if (!availableWidth || this.availableWidth == availableWidth) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
this.availableWidth = availableWidth;
|
|
291
|
+
|
|
292
|
+
for (let i = this.maxColumns; i > 0; i--) {
|
|
293
|
+
let neededWidth = this.cardMinWidth * i + this.gap * (i - 1);
|
|
294
|
+
if (neededWidth <= availableWidth) {
|
|
295
|
+
count = i;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
this.columnCount = count;
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
</script>
|
|
304
|
+
|
|
305
|
+
<style lang="scss">
|
|
306
|
+
@use '../styles/px.scss' as *;
|
|
307
|
+
|
|
308
|
+
.px-card-grid {
|
|
309
|
+
width: 100%;
|
|
310
|
+
max-width: 100%;
|
|
311
|
+
|
|
312
|
+
&__grid {
|
|
313
|
+
display: grid;
|
|
314
|
+
grid-gap: var(--gap);
|
|
315
|
+
justify-content: center;
|
|
316
|
+
margin: 0 auto;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
&__row {
|
|
320
|
+
display: contents;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
&__space {
|
|
324
|
+
position: relative;
|
|
325
|
+
display: flex;
|
|
326
|
+
flex-direction: column;
|
|
327
|
+
justify-content: stretch;
|
|
328
|
+
align-items: stretch;
|
|
329
|
+
grid-gap: var(--gap);
|
|
330
|
+
gap: var(--gap);
|
|
331
|
+
|
|
332
|
+
&--layout-stacked {
|
|
333
|
+
grid-column: span 1 / auto;
|
|
334
|
+
aspect-ratio: var(--aspect);
|
|
335
|
+
// prettier-ignore
|
|
336
|
+
@include grid(
|
|
337
|
+
'100% | ',
|
|
338
|
+
'top | #(0, 1fr)',
|
|
339
|
+
'bottom | #(0, 1fr)'
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
&--layout-default {
|
|
344
|
+
grid-column: span 1;
|
|
345
|
+
aspect-ratio: var(--aspect);
|
|
346
|
+
@include grid('100% | ', 'card | #(0, 1fr)');
|
|
347
|
+
}
|
|
348
|
+
&--layout-wide {
|
|
349
|
+
grid-column: span 2;
|
|
350
|
+
//aspect-ratio: var(--aspect-wide);
|
|
351
|
+
|
|
352
|
+
@include grid('100% | ', 'card | #(0, 1fr)');
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
&__card {
|
|
357
|
+
display: grid;
|
|
358
|
+
align-items: stretch;
|
|
359
|
+
justify-content: stretch;
|
|
360
|
+
position: relative;
|
|
361
|
+
flex: 1;
|
|
362
|
+
> * {
|
|
363
|
+
@include abs();
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// special case : wide columns in two columns need an aspect ration
|
|
368
|
+
&__grid--cols-2 & {
|
|
369
|
+
&__space--layout-wide {
|
|
370
|
+
aspect-ratio: var(--aspect-wide);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
&--debug & {
|
|
375
|
+
&__card {
|
|
376
|
+
@include after() {
|
|
377
|
+
@include abs;
|
|
378
|
+
background-color: rgba(red, 0.05);
|
|
379
|
+
border-radius: 5px;
|
|
380
|
+
border: 2px dashed rgba(red, 0.2);
|
|
381
|
+
pointer-events: none;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
</style>
|