0.2.0-alpha8 • Published 6 years ago

@unraid/shared-components v0.2.0-alpha8

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
6 years ago

shared-components

Usage Instructions

Add to your Unraid Vue.js project. Note that you must have access to the Unraid NPM Org and have an Access Token added to your ENV that has the correct permissions.

npm i @unraid/shared-components

Animated Unraid Logo Loader

<template>
    <div class="tw-flex tw-flex-wrap tw--mx-3">
        <div v-if="loading" class="tw-w-full tw-flex tw-justify-center tw-p-16">
            <unraid-loading class="tw-max-w-140px tw-px-3" />
        </div>
        <some-fancy-component v-else />
    </div>
</template>

<script>
import { UnraidLoading } from '@unraid/shared-components';
…
export default {
    …
    components: {
      UnraidLoading,
      …
    },
    …
};
</script>

SVG Icon Component

Uses svg-sprite to generate an SVG Sprite based on individual files with ./assets/svg/**/.

Then in Vue vue-svg-sprite is used within our .vue templates to display the SVGs from the generated SVG Sprite.

Pre-usage Setup

If you don't already have svg-sprite installed globally run yarn global add svg-sprite.

Because npm packages aren't really intended to have assets like images or font files we need to add a postinstall script to the parent project's package.json that will be using this SVG component of shared-components. This ensures the parent project can generate the SVG sprite and save it to the project's directory.

Step 1
"postinstall": "svg-sprite --config node_modules/@unraid/shared-components/svg-sprite.config.json 'node_modules/@unraid/shared-components/assets/svg/./**/*.svg'"
Step 2

You'll also want to update your .gitignore to include the directory that's created on postinstall

references that helped me figure this out:

Using the UnraidSvgIcon component in your project

Symbol names are automatically generated based on the individual SVG file's location. For example, if your SVG is located at assets/svg/ui/example.svg then the symbol prop value will be ui--example.

<template>
  <div>
    …
      <p class="tw-relative tw-mt-3 tw-pl-8">
        <!-- 
          - The symbol prop is required. Refer to SVGs in assets dir for options.
          - Uses classes to size and style your SVG
        -->
        <unraid-svg-icon 
          symbol="ui--example"
          class="tw-absolute tw-top-0 tw-left-0 tw-w-4 tw-h-4 tw-mr-2" />
        <a :href="exampleUrl" target="_blank">{{ exampleDetails }}</a>
      </p>
    …
  </div>
</template>
<script>
import { UnraidSvgIcon } from '@unraid/shared-components';
…
export default {
    …
    components: {
        …
        UnraidSvgIcon
    },
    …
}
</script>

Adding a new icon to the SVG Sprite (WIP)

  • Export your SVG with no fill. Sometimes in your editor this means setting the fill to #000000.
  • Remove any width or height attributes from the SVG Code (this may not be necessary, will determine soon)
  • Add your raw exported SVG file to assets/svg/<relevant_dir>/
  • Commit the new SVG to the repo
  • Push to origin
  • Now in your project you should be able to run yarn upgrade @unraid/shared-components to get the new version of the shared-components repo / "package".
    • Because we added the postinstall script to our project's package.json after running yarn the new version of the SVG Sprite was generated.
  • Now refer to the usage instructions above, referencing your new SVG via the symbol prop for the component.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

yarn install
yarn serve
yarn build
yarn test:unit
yarn test:e2e
yarn lint

Adding a Component

  1. Checkout a new topic branch
  2. Create your new .vue component file in src/components
  3. Import your new component to src/app.vue so you can see it for development purposes
  4. Add your new component to be exported src/components/index.js. Following the same naming convention that's already in place.
  • export { default as UnraidExample } from './example.vue';
  1. Commit your save points
  2. Once ready for other eyes create a PR
  3. Once PR is approved we will run npm publish to deploy latest version to NPM

TODO

  • Tests
0.1.37

4 years ago

0.1.36

5 years ago

0.1.35

5 years ago

0.1.34

5 years ago

0.1.33

5 years ago

0.1.31

5 years ago

0.1.30

5 years ago

0.1.28

6 years ago

0.1.27

6 years ago

0.1.26

6 years ago

0.1.25

6 years ago

0.1.23

6 years ago

0.1.22

6 years ago

0.1.21

6 years ago

0.1.20

6 years ago

0.1.19

6 years ago

0.1.18

6 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.2.0-alpha9

6 years ago

0.2.0-alpha8

6 years ago

0.2.0-alpha7

6 years ago

0.2.0-alpha6

6 years ago

0.2.0-alpha5

6 years ago

0.2.0-alpha4

6 years ago

0.2.0-alpha1

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago