Skip to content
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

feat: introduce components & directives #486

Merged
merged 19 commits into from May 25, 2021
Merged

feat: introduce components & directives #486

merged 19 commits into from May 25, 2021

Conversation

wheatjs
Copy link
Member

@wheatjs wheatjs commented May 3, 2021

Creating a draft PR for the components and directives so there can be open discussion about it as it is developed.

There are currently a few components and one directive. We still need to setup the infrastructure for actually exporting the components like we do the other utils. Also wondering how we should handle the documentation for them. We could include them in the index.md file for each component?

@cawa-93
Copy link
Member

cawa-93 commented May 9, 2021

Haven't you thought about putting all the components in a separate package, let's say @vueuse/components?

@wheatjs
Copy link
Member Author

wheatjs commented May 9, 2021

That was the original intention, but then we thought it would be easier to test and keep up to date if they were closer together.

@antfu
Copy link
Member

antfu commented May 9, 2021

Yeah, they will be put under the same folder with each function for organization, but published as @vueuse/components

@antfu antfu mentioned this pull request May 10, 2021
@antfu antfu changed the base branch from main to next May 11, 2021 18:28
@antfu
Copy link
Member

antfu commented May 11, 2021

Moved the target to next branch

@wheatjs
Copy link
Member Author

wheatjs commented May 11, 2021

Was wondering how we might like to handle options for components. Right now each component accepts an options attribute, but maybe we want to have an attribute for each option instead? For some I think it makes sense, although some with some options maybe it will create too many attributes, like with useFetch?

For example, right now if we have the component UseNow

<UseNow v-slot="{ now }" :options="{ interval: 10 }">
  {{ now }}
</UseNow>

If we were to expand these options out to attributes instead we could have

<UseNow v-slot="{ now }" :interval="10">
  {{ now }}
</UseNow>

I think the second option in general is nicer to use, but it would require more work to implement so I'd like to get some feedback on it before I did anything like that.

@antfu
Copy link
Member

antfu commented May 11, 2021

Could spread out, like

<UseNow v-slot="{ now }" :interval="10">
  {{ now }}
</UseNow>

And when you want to do options way:

<UseNow v-slot="{ now }" v-bind="{ interval: 10 }">
  {{ now }}
</UseNow>

@wheatjs
Copy link
Member Author

wheatjs commented May 11, 2021

Sounds good to me

@wheatjs
Copy link
Member Author

wheatjs commented May 15, 2021

Wondering how we should handle the docs for this. Should they be part of the same docs or maybe they should be separated, by something like tabs maybe? I guess the main thing we need right now is an easy way to test/demo them. It would be easier to see if everything is working like expected if we had a way to demo the main functions.

@wheatjs
Copy link
Member Author

wheatjs commented May 22, 2021

Ok so in total for our first release it looks like we will have 30 components including the following

  • onClickOutside
  • useActiveElement
  • useBattery
  • useBrowserLocation
  • useDark
  • useDeviceLight
  • useDeviceMotion
  • useDeviceOrientation
  • useDevicePixelRatio
  • useDevicesList
  • useDocumentVisibility
  • useElementBounding
  • useElementSIize
  • useElementVisibility
  • useFullscreen
  • useGeolocation
  • useIdle
  • useMouse
  • useMouseInElement
  • useMousePressed
  • useNetwork
  • useNow
  • useOnline
  • usePageLeave
  • usePreferredColorScheme
  • usePreferredDark
  • usePreferredLanguages
  • useTimeAgo
  • useTimestamp
  • useWindowSize

Each component includes minimal documentation showing basic usage.

@wheatjs wheatjs requested a review from antfu May 22, 2021 08:00
@antfu antfu marked this pull request as ready for review May 25, 2021 09:52
@antfu antfu changed the title feat!: introduce components & directives feat: introduce components & directives May 25, 2021
@antfu antfu merged commit 5bede93 into next May 25, 2021
@antfu antfu deleted the feat/components branch May 25, 2021 09:52
antfu added a commit that referenced this pull request Jun 6, 2021
* feat(useTransition): support for vectors (#376)

* refactor(useTransition): cleaning up (#385)

* refactor(useWebWorkerFn): Small doc and type improvements (#382)

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>

* feat: pwa reload prompt

* chore: update docs

* refactor(useWebWorkerFn): Small doc and type improvements (#382)

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>

* chore: update docs

* test: simpilfy tests for useTransition

* chore: fix tests

* feat(useTransition): support for delayed transitions (#386)

* feat(useTransition): support for disabled transitions (#436)

* feat!: introduce `controls` option

* chore: update

* chore: update

* refactor(useRafFn): remove depreacted APIs

* chore: enabled tests for next branch

* fix(useFetch)!: allow setting response type before doing request (#454)

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>

* chore: resolve conflicts

* feat(useMediaControls): expose source types (#495)

* fix(useMediaControls): Removes tracks that have been inserted in html (#493)

* chore: release v4.9.3

* fix(usePermission): tolerate error on FireFox

* fix(useDevicesList): treat as premssion granted after getUserMedia

* chore: release v4.9.4

* chore: fix typo (#502)

* feat(useWebSocket): add immediate option (#503)

* feat(useAxios): bring API into line with useFetch (#499)

* feat(createEventHook): new function (#497)

* chore: release v4.10.0

* fix(useMediaControls): Doesn't rewrite default media properties (#500)

* feat(useMediaControls): add error event (#509)

* feat(useStorage): optimize event handling logic (#505)

* feat(useFetch): add afterFetch option, onFetchResponse, and onFetchError (#506)

* feat(useWebWoker): return worker (#507)

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>

* fix: Change `onMediaError` to `onSourceError` (#510)

* feat(onClickOutside): default to just pointerDown (#508)

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
Co-authored-by: sibbng <sibbngheid@gmail.com>

* chore: update docs

* chore: release v4.11.0

* fix(onClickOutside): duplicate code (#519)

Co-authored-by: Nurettin Kaya <sibbngheid@gmail.com>

* feat(createEventHook): added interface (#531)

* feat(createEventHook): added interface

* added types for EventHookOn, EventHookOff, and EventHook trigger

* feat(useStorage): allow custom serializer (#528)

* feat(useStorage): allow custom serializer

* update test

* refactor(useMediaControls): Deprecate options that can simply be set as attributes (#514)

* useMediaControls: Add `volumechange` event listener

* fix: `mute` returned

* feat: Deprecate video options:
* `poster`
* `autoplay`
* `preload`
* `loop`
* `controls`
* `playsinline`
* `autoPictureInPicture`

* fix: Fix deprecated behaviour in demo

* fix: Remove deprecated usage from doc

* refactor: More polite messages

* fix: Remove `console.warn`s

* chore: release v4.11.1

* refactor!: remove deprecated apis

* chore: add next tag

* chore: release v5.0.0-beta.1

* feat: introduce `components` & `directives` (#486)

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>

* docs: re-organize

* chore: fix lint

* docs: about components

* chore: include directives

* chore: release v5.0.0-beta.2

* chore: rollback jest

* chore: fix docs build

* docs: readme for components

* docs: add @vueuse/gesture

* chore: ship indexes.json

* chore: release v5.0.0-beta.3

* feat(typedef): add return typedefs (#543) (#544)

* refactor!: change publish strcture and support submodules, close #469

* chore: cleanup stories.tsx

* docs: update docs about submodules

* chore: fix docs

* chore: release v5.0.0-beta.4

* chore: update lock

* chore: release v5.0.0-beta.5

* chore: update deps and extend publish memory

* refactor: remove `useDeviceLight`

* chore: update

* chore: fix tests

* chore: release v5.0.0-beta.7

* refactor(useWebSocket)!: change immediate default for 5.0.0 (#545)

* feat(useIpcRenderer): new add-one & new functions (#547)

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>

* chore: update deps

* chore: release v5.0.0-beta.8

* chore: fix docs build

* chore(usePointerSwipe): fix typo (#557)

* fix(useAuth): now reqiures the auth instance, close #538

* chore: update deps

* docs(biSyncRef): fix console output comment (#555)

* docs: removed deprecated value from example (#556)

* docs(guidlines): added guidelines (#535)

* docs: update guidelines

* chore: update guidelines

Co-authored-by: Scott Bedard <scottbedard@users.noreply.github.com>
Co-authored-by: Fabian <donskelle@googlemail.com>
Co-authored-by: Ismail Gjevori <isgjevori@protonmail.com>
Co-authored-by: Alex Kozack <cawa-93@users.noreply.github.com>
Co-authored-by: Shinigami <chrissi92@hotmail.de>
Co-authored-by: wheat <jacobrclevenger@gmail.com>
Co-authored-by: sibbng <sibbngheid@gmail.com>
Co-authored-by: JserWang <jserwang@gmail.com>
Co-authored-by: Pig Fang <g-plane@hotmail.com>
Co-authored-by: ArcherGu <34826812+ArcherGu@users.noreply.github.com>
Co-authored-by: Ilya Komichev <hello@ilko.me>
Co-authored-by: Daiki Ojima <daiking.ca2@gmail.com>
Co-authored-by: Manaus <manaustransez@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants