globalbrain / sefirot

Global Brain Design System.
https://sefirot.globalbrains.com
MIT License
151 stars 12 forks source link

feat(dropdown): add date range section #427

Closed kiaking closed 10 months ago

kiaking commented 10 months ago

Add dropdown section to handle "Date Range" selection.

I've added new class DateRange which holds from and to dates, with presets. The usage would look like this.

<script setup lang="ts">
// Create a new `DateRange` instance.
const range = shallowRef(new DateRange())

const sections = [
  createDropdownDateRange({
    range,

    // This callback will only be called when user hits
    // `Apply` button in dropdown menu.
    onApply: (r) => { range.value = r }
  })
]

// Access `from` and `to` value.
range.value.getFrom() // Day instance
range.value.getTo()   // Day instance
</script>

<template>
<SDropdown :sections="sections" />
</template>

You can define custom preset as a default value by creating the preset at the beginning.

const range = shallowRef(
  new DateRange.setPreset(
    new YearHalf().setYear(2018).setHalf(2)
  )
)

Screenshot 2023-12-25 at 16 57 34 Screenshot 2023-12-25 at 16 57 50
netlify[bot] commented 10 months ago

Deploy Preview for sefirot-story ready!

Name Link
Latest commit d405da4b47fa6cd6aa597170fcb6f6ceeef9243a
Latest deploy log https://app.netlify.com/sites/sefirot-story/deploys/658b97cc54aa010008949daa
Deploy Preview https://deploy-preview-427--sefirot-story.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] commented 10 months ago

Deploy Preview for sefirot-docs ready!

Name Link
Latest commit d405da4b47fa6cd6aa597170fcb6f6ceeef9243a
Latest deploy log https://app.netlify.com/sites/sefirot-docs/deploys/658b97cc20ff8200086a407a
Deploy Preview https://deploy-preview-427--sefirot-docs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.