4.1.13 • Published 4 months ago

@thinkpixellab-public/px-vue v4.1.13

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

px-vue

Storybook

Basic component preview and testing can be done with storybook. Run storybook with npm run dev-px.

Migration Notes / Approach

Two-way Props / v-model

Move away from .sync and use v-model with an argument instead

Minimal v-model Implementation

The minimal implementation allows the parent component to "own" data and pass it the child component as a prop. If the child component wants to update the value, it does so by emitting an event with the preferred value.

<MyComponent v-model:selected="selected" />
{
    emits: ['update:selected'],
    props: {
        selected: { default: null }
    },
    methods: {
        updateSelected(selectedValue) {
            this.$emit('update:selected', selectedValue);
        }
    }
}

Local Data v-model Implementation

In many cases a component should be able to update the data without requiring a parent component to actually provide the data store. In this case we create a data property and keep it in sync with the prop.

By convention the internal data field has the same name ast the prop with "Value" appended. If the prop were named selected, for example, the corresponding data field would be named selectedValue. Internally the component should always use selectedValue instead of selected.

<MyComponent v-model:selected="selected" />
emits: ['update:selected'],
props: {
    selected: { default: null }
},
data() {
    return {
        selectedValue: this.selected
    };
},
watch: {
    selected(nv) {
        this.selectedValue = nv;
    },

    selectedValue(nv) {
        this.$emit('update:selected', nv);
    }
}

Styles / Customization

  • Component Fallbacks Hardcoded values defined in the component style.
  • Component Variants Overrides defined within the component

App Defaults App Scoped Defaults App Variants

Usage Defaults Usage Class

Style

FAQ

Where should component styles be defined?

TLDR

  1. Use expanded (non-mixin) CSS as much as possible right in the component.

  2. Repeating styles (e.g. a popup or a button) should generally have their own component and variants for that style.

Since we use single file components, these should obviously be defined in the component. That said, many of our more generic components are currently using px-styles mixins for this (i.e. the whole style section could just be something like @include button()) and I think we should move away from that and instead keep as much of the component's css in an "expanded" state as possible. This makes it much easier to understand what's going on.

Where should styling defaults come from?

We want to have a hierarchy that roughly looks like this:

  1. The component should provide default values in a way that no external CSS or configuration is necessary to get a generic version of the component.

  2. It should be straightforward to define app defaults and these can be encapsulated into a shareable "theme" file that can be customized / used for projects. It also might make sense to have different levels of specificity in that theme. For example a property like "border-radius" might be shared by many controls (button, textbox, dropdown, etc.) so it would make sense that you can define an app-level default for that. But you should also be able to have different values for different components

  3. It makes sense that the component can

Component Defaults App Defaults (with levels of specificty) Variants App Variants

<style>

When should we use CSS variables in custom components?

Is it useful to reexpose CSS variables for properties that already exist like border radius (e.g. px-textbox-border-radius)? It doesn't seem like it because you would define it at the root as the default and then again at usage. Might as well just use border-radius. What about for global defaults? For that we can use SASS config/vars.

On the other hand, it does seem useful to use CSS variables for high level concepts that don't have a semantically equivalent CSS property but would make sense to customize. An example of this might be something like '--toggle-track-background' or in a toggle switch or '--dropdown-arrow-svg' in a dropdown.

These can then be treated like other CSS properties where they would take their default from a SCSS config (with a fallaback) but then be easily overriden in a local style or class.

When should we use v-bind to expose style-related properties as props?

If the value is likely to change a lot based on usage then maybe it makes sense to do this but I think it is rare. Most of the time it's better keep CSS modifications in CSS. Keep styling in styles/CSS for the most part. This doesn't mean never use v-bind in CSS, it just means that we don't want to arbitraily expose many CSS properties as props on the component because it just becomes unclear how you should style or modify the component.


Default README

This template should help get you started developing with Vue 3 in Vite.

Recommended IDE Setup

VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).

Customize configuration

See Vite Configuration Reference.

Project Setup

npm install

Compile and Hot-Reload for Development

npm run dev

Compile and Minify for Production

npm run build

Run Unit Tests with Vitest

npm run test:unit

Lint with ESLint

npm run lint
4.1.13

4 months ago

4.1.9

4 months ago

4.1.8

4 months ago

4.1.7

4 months ago

4.1.4

5 months ago

4.1.6

4 months ago

4.1.5

4 months ago

4.1.3

5 months ago

4.1.2

5 months ago

4.0.30

5 months ago

4.1.0

5 months ago

4.1.1

5 months ago

4.0.29

7 months ago

4.0.27

7 months ago

4.0.28

7 months ago

4.0.26

8 months ago

4.0.21

9 months ago

4.0.23

9 months ago

4.0.22

9 months ago

4.0.25

8 months ago

4.0.24

9 months ago

3.0.109

10 months ago

3.0.108

10 months ago

3.0.110

9 months ago

3.0.103

1 year ago

3.0.102

1 year ago

3.0.105

1 year ago

3.0.104

1 year ago

3.0.107

1 year ago

3.0.106

1 year ago

4.0.19

10 months ago

4.0.20

9 months ago

4.0.16

12 months ago

4.0.15

12 months ago

4.0.18

10 months ago

4.0.17

11 months ago

4.0.12

1 year ago

4.0.11

1 year ago

4.0.14

12 months ago

4.0.13

12 months ago

3.0.101

1 year ago

3.0.99

1 year ago

3.0.100

1 year ago

3.0.98

1 year ago

3.0.97

1 year ago

3.0.96

1 year ago

3.0.95

1 year ago

3.0.94

1 year ago

3.0.93

1 year ago

3.0.92

1 year ago

3.0.91

1 year ago

3.0.90

1 year ago

4.0.10

1 year ago

3.0.89

1 year ago

3.0.88

1 year ago

3.0.87

1 year ago

3.0.86

1 year ago

3.0.85

1 year ago

3.0.83

1 year ago

3.0.84

1 year ago

3.0.82

1 year ago

3.0.81

2 years ago

3.0.80

2 years ago

3.0.79

2 years ago

3.0.78

2 years ago

3.0.77

2 years ago

3.0.76

2 years ago

3.0.56

2 years ago

3.0.57

2 years ago

3.0.54

2 years ago

3.0.55

2 years ago

3.0.58

2 years ago

3.0.59

2 years ago

3.0.53

2 years ago

3.0.67

2 years ago

3.0.68

2 years ago

3.0.65

2 years ago

3.0.66

2 years ago

3.0.69

2 years ago

3.0.60

2 years ago

3.0.63

2 years ago

3.0.64

2 years ago

3.0.61

2 years ago

3.0.62

2 years ago

3.0.70

2 years ago

3.0.71

2 years ago

3.0.74

2 years ago

3.0.75

2 years ago

3.0.72

2 years ago

3.0.73

2 years ago

3.0.51

2 years ago

3.0.50

2 years ago

4.0.5

2 years ago

4.0.4

2 years ago

4.0.7

2 years ago

4.0.6

2 years ago

4.0.3

2 years ago

4.0.9

2 years ago

4.0.8

2 years ago

3.0.45

2 years ago

3.0.46

2 years ago

3.0.43

2 years ago

3.0.44

2 years ago

3.0.49

2 years ago

3.0.47

2 years ago

3.0.48

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

4.0.2

2 years ago

3.0.41

2 years ago

3.0.42

2 years ago

3.0.40

2 years ago

3.0.39

2 years ago

3.0.38

2 years ago

3.0.36

2 years ago

3.0.37

2 years ago

3.0.34

2 years ago

3.0.35

2 years ago

3.0.32

2 years ago

3.0.33

2 years ago

3.0.27

3 years ago

3.0.28

2 years ago

3.0.26

3 years ago

3.0.30

2 years ago

3.0.31

2 years ago

3.0.29

2 years ago

3.0.23

3 years ago

3.0.24

3 years ago

3.0.21

3 years ago

3.0.22

3 years ago

3.0.25

3 years ago

3.0.20

3 years ago

3.0.18

3 years ago

3.0.19

3 years ago

3.0.12

3 years ago

3.0.13

3 years ago

3.0.11

3 years ago

3.0.16

3 years ago

3.0.17

3 years ago

3.0.14

3 years ago

3.0.15

3 years ago

3.0.10

3 years ago

3.0.9

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago