-
Notifications
You must be signed in to change notification settings - Fork 5
feat: create YearRangeFilter component #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 145 commits
Commits
Show all changes
151 commits
Select commit
Hold shift + click to select a range
db8da7f
adds components list
dChiamp bd57d86
Update COMPONENTS.md
Sveb 4fa76ad
Update COMPONENTS.md
Sveb b4dc86d
Update COMPONENTS.md
Sveb 285e079
Update COMPONENTS.md
Sveb 213a640
adds notes
dChiamp 3004c74
Update COMPONENTS.md
Sveb 7a1e0aa
Merge branch 'main' of https://github.com/funkhaus/ucla-library-websi…
dChiamp e955637
claimed component
austinblanchard d5e45d1
Update COMPONENTS.md
Sveb d49eaf5
claim a component
lux-v 4b6cccf
claim a component
lux-v bfa79d4
Update COMPONENTS.md
Sveb 4852133
Update COMPONENTS.md
Sveb 2120974
Update COMPONENTS.md
Sveb c5d0581
take a component
lux-v af0a6b3
take a component
lux-v 2e73be7
take a component
lux-v 88bfe5e
Update COMPONENTS.md
austinblanchard 22b88d7
Update COMPONENTS.md
Sveb 498ab73
Adjust the component name - already exists
Sveb 09c2fd0
take a component
lux-v 0c75f77
take a component
lux-v a7bf5fa
Update COMPONENTS.md
Sveb 069c123
Update COMPONENTS.md
Sveb cdb4a86
Update COMPONENTS.md
Sveb 8a29837
Update COMPONENTS.md
austinblanchard 7bdfa7a
Update COMPONENTS.md - marking BentoPod
Sveb bc0154d
add component
lux-v 597ef57
add component
lux-v 02aafc7
Update COMPONENTS.md
austinblanchard e675c1b
Update COMPONENTS.md
austinblanchard 2933c6d
take a component
lux-v d5c665a
take a component
lux-v e539e14
fix component description
lux-v 4808e2d
Update COMPONENTS.md
Sveb e372e04
Update COMPONENTS.md
Sveb 7d5d656
change component's name
lux-v ed656cf
Update COMPONENTS.md
Sveb 877fb65
take a component
lux-v 348494b
take a component
lux-v 45e6cf7
take a component
lux-v 183375c
remove AssetFeaturedImage definition
lux-v ee9dd92
take a component
lux-v 62919e6
take a components
lux-v 51430d6
take a components
lux-v f6de890
take a component
lux-v 76226de
take a component
lux-v d78dda6
add a new line
lux-v 7388620
add detailed component description
lux-v 63b619b
add detailed component description
lux-v e277dbe
take a component
lux-v 08e03ec
update component description
lux-v 0ee907a
Adds a button component
Sveb 864171d
Update COMPONENTS.md
Sveb 1bb618a
Update COMPONENTS.md
Sveb 54df91d
Update COMPONENTS.md
Sveb 0ed4fbb
Clean up components.md
Sveb b06efac
Taking the block-collection component
Sveb d31c91f
Taking the grid-collections component as well.
Sveb 94304d5
Update COMPONENTS.md
Sveb 279744a
Clean up component list
Sveb 82e0566
add spacing
lux-v d24c553
add spacing
lux-v c69bfac
Merge branch 'UCLALibrary:main' into main
lux-v 0f9c0aa
update component name
lux-v a10aa20
Update Button definition
lux-v 7f9084e
Update COMPONENTS.md
lux-v 4b9de5d
Update COMPONENTS.md
lux-v f3b329f
Remove duplicates
lux-v 2f4300d
remove duplicates
lux-v 2cde0d3
remove duplicates
lux-v df42ca4
Remove already existing components
lux-v 3db154c
Merge branch 'main' into main
lux-v 9287f6d
take a component
lux-v 33787b8
update package
Sveb fe7041b
add a component
lux-v 05911af
Take a component
Sveb 92f95f4
adjust prop for block anchor nav
lux-v b876c86
take a component
lux-v 1d0497d
Update COMPONENTS.md
lux-v 2e670a6
Merge remote-tracking branch 'upstream/main'
Sveb eec9a91
Merge branch 'main' into main
lux-v 09043d2
Merge remote-tracking branch 'upstream/main'
Sveb 4a3040f
Taking the DropdownSingleSelect
Sveb 99240ef
Merge remote-tracking branch 'upstream/main'
Sveb f72144c
Take the ButtonDropdownSearch component
Sveb 8301316
Merge remote-tracking branch 'upstream/main'
Sveb 9beaa8f
Merge branch 'UCLALibrary:main' into main
lux-v b87f27e
Merge remote-tracking branch 'upstream/main'
Sveb 95d50e6
adding the correct packageMenager version for netlify to see.
Sveb 3aeb5a6
Merge pull request #30 from Sveb/installing-the-correct-pnpnm
Sveb 16e863a
Merge remote-tracking branch 'upstream/main'
Sveb 73a286e
Merge branch 'UCLALibrary:main' into main
lux-v 64208d8
Merge remote-tracking branch 'upstream/main'
Sveb f3e47de
Update COMPONENTS.md
Sveb cab92c8
Merge branch 'UCLALibrary:main' into main
lux-v 4284ea6
Marking a component as taken
Sveb d7ec61c
Merge remote-tracking branch 'upstream/main'
Sveb 8817e3b
feat: create the year-range-slider component
Sveb 170b39f
Remove packageManager field from package.json
Sveb c2a2e75
Merge remote-tracking branch 'upstream/main'
Sveb 83dd2d4
Merge branch 'main' into year-range-slider
Sveb 039a509
Update packages/vue-component-library/src/index.ts
Sveb 7df1d2f
clean up stories.
Sveb 336fda4
Update component statuses and remove completed items
Sveb 33211f0
Merge remote-tracking branch 'upstream/main'
Sveb fb8fc47
Merge branch 'UCLALibrary:main' into main
lux-v fe816e4
Merge remote-tracking branch 'upstream/main'
Sveb 21bfbcd
Update COMPONENTS.md
Sveb b8a8d23
Taking the FiltersDropdown
Sveb 345f8b9
Update COMPONENTS.md
lux-v 89788c4
Add note regarding existing header component tweaks
lux-v cfbbcd4
Update RefineSearchPanel ownership in COMPONENTS.md
Sveb 12b0865
Merge remote-tracking branch 'upstream/main'
Sveb 90661b7
Update DetailMedia component owner to Svebor
Sveb 12725ef
Update component list
austinblanchard 202ef87
Merge branch 'UCLALibrary:main' into main
lux-v 690b044
Clarify CTAHexButton entry in COMPONENTS.md
lux-v 3fe1723
Update COMPONENTS.md to remove and modify components
Sveb daf45e8
Merge remote-tracking branch 'upstream/main'
Sveb 6bc549e
Update component status and ownership in COMPONENTS.md
Sveb f570d75
Update component ownership in COMPONENTS.md
Sveb 5a8fab1
Merge branch 'UCLALibrary:main' into main
lux-v d902719
Merge branch 'UCLALibrary:main' into main
lux-v 9dc1550
Merge remote-tracking branch 'upstream/main'
Sveb fb48e3b
Merge branch 'UCLALibrary:main' into main
lux-v d660e03
Merge remote-tracking branch 'upstream/main'
Sveb e8a0500
Merge branch 'UCLALibrary:main' into main
lux-v 50aeb69
Merge branch 'UCLALibrary:main' into main
lux-v c8f5fbb
Merge branch 'UCLALibrary:main' into main
lux-v cdea736
Merge remote-tracking branch 'upstream/main'
Sveb 26a60ed
Merge branch 'UCLALibrary:main' into main
lux-v a214856
Merge branch 'UCLALibrary:main' into main
lux-v 78b03ee
Merge branch 'UCLALibrary:main' into main
lux-v 84c0b0a
Merge branch 'UCLALibrary:main' into main
lux-v db8bcf4
Merge remote-tracking branch 'upstream/main'
Sveb 9778bff
Merge branch 'UCLALibrary:main' into main
lux-v 5ad9942
Merge branch 'UCLALibrary:main' into main
lux-v 8e12a81
Merge branch 'main' into year-range-slider
Sveb 1e8a0da
Merge branch 'main' into year-range-slider
Sveb 2199948
Merge remote-tracking branch 'upstream/main' into year-range-slider
Sveb d57aa38
Update package.json
Sveb 26559da
Merge branch 'main' into year-range-slider
pghorpade 4afd9db
Merge branch 'main' into year-range-slider
pghorpade 3c931de
Adds to the route queries
Sveb cf4a4e7
Merge branch 'main' into year-range-slider
pghorpade a9aa07e
Adjusts the year range slider so it allows for typing and increments …
Sveb d1ed9fd
Update YearRangeFilter.stories.js
Sveb 08b13b3
Adds a visual debugging feature to the story
Sveb 098e567
Merge branch 'main' into year-range-slider
pghorpade File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| Designs: | ||
| https://www.figma.com/design/CDhWDARLb36ftkQce1LyLC/Breakpoints?node-id=1-25&m=dev | ||
|
|
||
| https://www.figma.com/design/CDhWDARLb36ftkQce1LyLC/Breakpoints?node-id=1-26&p=f&m=dev | ||
|
|
||
| Read in Recording: | ||
| https://drive.google.com/file/d/17tiGmE4aax-faoo5Rjue2Idbx3OGCFGa/view?usp=sharing | ||
|
|
||
| Relevant Links | ||
| https://www.library.ucla.edu/ | ||
| https://digital.library.ucla.edu/catalog/ark:/21198/z1x98m6j | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
219 changes: 219 additions & 0 deletions
219
packages/vue-component-library/src/lib-components/YearRangeFilter.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,219 @@ | ||
| <script setup lang="ts"> | ||
| import { computed, ref, watch } from 'vue' | ||
| import { useTheme } from '@/composables/useTheme' | ||
|
|
||
| // Props | ||
| interface YearRangeFilterProps { | ||
| min: number | ||
| max: number | ||
| minValue: number | ||
| maxValue: number | ||
| step: number | ||
| disabled: boolean | ||
| } | ||
| const props = defineProps<YearRangeFilterProps>() | ||
|
||
|
|
||
| // Emits | ||
| const emit = defineEmits(['update:minValue', 'update:maxValue', 'change']) | ||
|
|
||
| // THEME | ||
| const theme = useTheme() | ||
| const classes = computed(() => { | ||
| return ['year-range-filter', theme?.value || ''] | ||
| }) | ||
|
|
||
| // Local state for the input values | ||
| const localMinValue = ref(props.minValue) | ||
| const localMaxValue = ref(props.maxValue) | ||
|
|
||
| // Watch for prop changes | ||
| watch(() => props.minValue, (newVal) => { | ||
| localMinValue.value = newVal | ||
| }) | ||
|
|
||
| watch(() => props.maxValue, (newVal) => { | ||
| localMaxValue.value = newVal | ||
| }) | ||
|
|
||
| // Handle input changes | ||
| function handleMinInput(event: Event) { | ||
| const target = event.target as HTMLInputElement | null | ||
| if (!target) | ||
| return | ||
|
|
||
| const value = Number.parseInt(target.value) || props.min | ||
| const clampedValue = Math.max(props.min, Math.min(value, localMaxValue.value - props.step)) | ||
| localMinValue.value = clampedValue | ||
| emit('update:minValue', clampedValue) | ||
| emit('change', { min: clampedValue, max: localMaxValue.value }) | ||
| } | ||
|
|
||
| function handleMaxInput(event: Event) { | ||
| const target = event.target as HTMLInputElement | null | ||
| if (!target) | ||
| return | ||
|
|
||
| const value = Number.parseInt(target.value) || props.max | ||
| const clampedValue = Math.min(props.max, Math.max(value, localMinValue.value + props.step)) | ||
| localMaxValue.value = clampedValue | ||
| emit('update:maxValue', clampedValue) | ||
| emit('change', { min: localMinValue.value, max: clampedValue }) | ||
| } | ||
|
|
||
| // Handle slider changes | ||
| function handleSliderChange(event: Event) { | ||
| const target = event.target as HTMLInputElement | null | ||
| if (!target) | ||
| return | ||
|
|
||
| const value = Number.parseInt(target.value) | ||
|
|
||
| if (target.dataset.handle === 'min') { | ||
| // Prevent min slider from going beyond max slider | ||
| const clampedValue = Math.max(props.min, Math.min(value, localMaxValue.value - props.step)) | ||
| localMinValue.value = clampedValue | ||
| // Update the slider value to match the clamped value | ||
| target.value = clampedValue.toString() | ||
| emit('update:minValue', clampedValue) | ||
| } | ||
|
|
||
| else { | ||
| // Prevent max slider from going below min slider | ||
| const clampedValue = Math.min(props.max, Math.max(value, localMinValue.value + props.step)) | ||
| localMaxValue.value = clampedValue | ||
| // Update the slider value to match the clamped value | ||
| target.value = clampedValue.toString() | ||
| emit('update:maxValue', clampedValue) | ||
| } | ||
| emit('change', { min: localMinValue.value, max: localMaxValue.value }) | ||
| } | ||
|
|
||
| // Handle mouse events to determine which slider to interact with | ||
| function handleSliderMouseDown(event: Event) { | ||
| const target = event.currentTarget as HTMLElement | null | ||
| if (!target) | ||
| return | ||
|
|
||
| const rect = target.getBoundingClientRect() | ||
| // Ensure event is a MouseEvent to access clientX | ||
| if (!(event instanceof MouseEvent)) | ||
| return | ||
|
|
||
| const x = event.clientX - rect.left | ||
| const width = rect.width | ||
| const percentage = x / width | ||
|
|
||
| // Determine which slider is closer to the click position | ||
| const minPosition = (localMinValue.value - props.min) / (props.max - props.min) | ||
| const maxPosition = (localMaxValue.value - props.min) / (props.max - props.min) | ||
|
|
||
| const minDistance = Math.abs(percentage - minPosition) | ||
| const maxDistance = Math.abs(percentage - maxPosition) | ||
|
|
||
| if (minDistance < maxDistance) { | ||
| // Focus on min slider | ||
| const minSlider = (event.currentTarget as HTMLElement | null)?.querySelector('.range-slider--min') as HTMLElement | null | ||
| if (minSlider) | ||
| minSlider.focus() | ||
| } | ||
| else { | ||
| // Focus on max slider | ||
| const maxSlider = (event.currentTarget as HTMLElement | null)?.querySelector('.range-slider--max') as HTMLElement | null | ||
| if (maxSlider) | ||
| maxSlider.focus() | ||
| } | ||
| } | ||
|
|
||
| // Handle limit button click | ||
| function handleLimitClick() { | ||
| emit('change', { min: localMinValue.value, max: localMaxValue.value }) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Router integration on “Limit”
|
||
| } | ||
|
|
||
| // Computed styles for the range track | ||
| const trackStyle = computed(() => { | ||
| const minPercent = ((localMinValue.value - props.min) / (props.max - props.min)) * 100 | ||
| const maxPercent = ((localMaxValue.value - props.min) / (props.max - props.min)) * 100 | ||
| return { | ||
| background: `linear-gradient(to right, | ||
| var(--color-secondary-grey-02) 0%, | ||
| var(--color-secondary-grey-02) ${minPercent}%, | ||
| var(--color-primary-blue-03) ${minPercent}%, | ||
| var(--color-primary-blue-03) ${maxPercent}%, | ||
| var(--color-secondary-grey-02) ${maxPercent}%, | ||
| var(--color-secondary-grey-02) 100%)` | ||
| } | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div :class="classes"> | ||
| <!-- Input fields and button row --> | ||
| <div class="range-inputs"> | ||
| <input | ||
| v-model.number="localMinValue" | ||
| type="number" | ||
| :min="min" | ||
| :max="max" | ||
| :step="step" | ||
| :disabled="disabled" | ||
| class="range-number-input range-input--min" | ||
| @input="handleMinInput" | ||
| > | ||
| <span class="range-separator" /> | ||
| <input | ||
| v-model.number="localMaxValue" | ||
| type="number" | ||
| :min="min" | ||
| :max="max" | ||
| :step="step" | ||
| :disabled="disabled" | ||
| class="range-number-input range-input--max" | ||
| @input="handleMaxInput" | ||
| > | ||
| <button | ||
| type="button" | ||
| class="limit-button" | ||
| :disabled="disabled" | ||
| @click="handleLimitClick" | ||
| > | ||
| Limit | ||
| </button> | ||
| </div> | ||
|
|
||
| <!-- Range slider --> | ||
| <div class="range-slider-container"> | ||
| <div | ||
| class="range-track" | ||
| :style="trackStyle" | ||
| @mousedown="handleSliderMouseDown" | ||
| > | ||
| <input | ||
| type="range" | ||
| :min="min" | ||
| :max="max" | ||
| :step="step" | ||
| :value="localMinValue" | ||
| :disabled="disabled" | ||
| class="range-slider range-slider--min" | ||
| data-handle="min" | ||
| @input="handleSliderChange" | ||
| > | ||
| <input | ||
| type="range" | ||
| :min="min" | ||
| :max="max" | ||
| :step="step" | ||
| :value="localMaxValue" | ||
| :disabled="disabled" | ||
| class="range-slider range-slider--max" | ||
| data-handle="max" | ||
| @input="handleSliderChange" | ||
| > | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <style lang="scss" scoped> | ||
| @import '@/styles/dlc/_year-range-filter.scss'; | ||
| </style> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this file