Code Monkey home page Code Monkey logo

vue's Introduction

Important

As part of a major update, we will be replacing the existing phosphor-vue package with @phosphor-icons/vue. We recommend using this new version, as it has improved performance and significantly smaller bundle size. No APIs have been changed, so drop-in replacement should be straightforward. The legacy package will continue to recieve maintenance, but will not be updated with new icons upstream. Take me to the legacy version ➜

Vue Phosphor icons

Phosphor is a flexible icon family for interfaces, diagrams, presentations — whatever, really. Explore all our icons at phosphoricons.com.

NPM JavaScript Style Guide Travis

GitHub stars GitHub forks GitHub watchers Follow on GitHub

Playground

Check out our playground in StackBlitz and start experimenting!

Open in StackBlitz

Installation

yarn add @phosphor-icons/vue

or

npm install @phosphor-icons/vue

Usage

<template>
  <PhHorse />
  <PhHeart :size="32" color="hotpink" weight="fill" />
  <PhCube />
</template>

<script lang="ts" setup>
  import { PhHorse, PhHeart, PhCube } from "@phosphor-icons/vue";
</script>

Global install

Allthough we strongly advise against installing your icons globally, you can do so by registering it in your app as follows:

import { createApp } from 'vue'
import App from './App.vue'
import PhosphorIcons from "@phosphor-icons/vue"

let app = createApp(App)

app.use(PhosphorIcons)

app.mount('#app')

Note

Why do we advise against global installs?

Bundlers such as Vite and Webpack rely on ESM imports to do tree-shaking. When you install entire library globally, you lose the ability to do tree-shaking, since all components are registered within vue, and the bundler cannot know which components are actually used in your app.

Props

Icon components accept all attributes that you can pass to a normal SVG element, including inline height/width, x/y, opacity, plus @click and other v-on handlers. The main way of styling them will usually be with the following props:

  • color?: string – Icon stroke/fill color. Can be any CSS color string, including hex, rgb, rgba, hsl, hsla, named colors, or the special currentColor variable.
  • size?: number | string – Icon height & width. As with standard React elements, this can be a number, or a string with units in px, %, em, rem, pt, cm, mm, in.
  • weight?: "thin" | "light" | "regular" | "bold" | "fill" | "duotone" – Icon weight/style. Can be used, for example, to "toggle" an icon's state: a rating component could use Stars with weight="regular" to denote an empty star, and weight="fill" to denote a filled star.
  • mirrored?: boolean – Flip the icon horizontally. Can be useful in RTL languages where normal icon orientation is not appropriate.

Composition

Phosphor takes advantage of Vue's provide/inject options to make applying a default style to all icons simple. Create a provide object or function at the root of the app (or anywhere above the icons in the tree) that returns a configuration object with props to be applied by default to all icons below it in the tree:

<template>
  <PhHorse /> {/* I'm lime-green, 32px, and bold! */}
  <PhHeart /> {/* Me too! */}
  <PhCube /> {/* Me three :) */}
</template>

<script lang="ts" setup>
  import { PhHorse, PhHeart, PhCube } from "@phosphor-icons/vue";
  import { provide } from "vue"

  provide("color", "limegreen")
  provide("size", 32)
  provide("weight", "bold")
  provide("mirrored", false)
</script>

You may create multiple providers for styling icons differently in separate regions of an application; icons use the nearest provider above them to determine their style.

Note

The color, size, weight, and mirrored properties are all optional props when creating a context, but default to "currentColor", "1em", "regular" and false.

Slots

Components have a <slot> for arbitrary SVG elements, so long as they are valid children of the <svg> element. This can be used to modify an icon with background layers or shapes, filters, animations and more. The slotted children will be placed below the normal icon contents.

The following will cause the Cube icon to rotate and pulse:

<template>
  <PhCube color="darkorchid" weight="duotone">
    <animate
      attributeName="opacity"
      values="0;1;0"
      dur="4s"
      repeatCount="indefinite"
    />
    <animateTransform
      attributeName="transform"
      attributeType="XML"
      type="rotate"
      dur="5s"
      from="0 0 0"
      to="360 0 0"
      repeatCount="indefinite"
    />
  </PhCube>
</template>

Note

The coordinate space of slotted elements is relative to the contents of the icon viewBox, which is a 256x256 square. Only valid SVG elements will be rendered.

Development

This repository leverages git-submodules to stay up-to-date with the phosphor-icons/core repository, which means that for local developoment, you'll need to clone this repository with the --recurse-submodules git clone flag.

After you've successfully cloned the repository, you will find a core directory containing the aforementioned core repository.

Now you can install all local dependencies with npm install and start developing.

Project structure

/bin: Holds the assembly script, which uses the raw SVG icon files from the core directory to assemble all Vue components

/core: Git submodule directory for the core repository

/dist: Will be created upon building the library and holds all dist bundles

/node_modules: You should know by now what this directory is about

/src: Holds the entry point for this library

Assembling

To assemble the Vue components you will need to run npm run assemble. This will loop through all icons in the /core/assets directory and create all Vue components including all weights and configuration props. These Vue components are then saved under /src/components which will then be used by the bundler to create the final package bundle.

NOTE: Upon cloning this repository, the /src/components directory does not exist yet. You will first need to run the assemble script for this directory to be generated.

Our Related Projects

Community Projects

If you've made a port of Phosphor and you want to see it here, just open a PR here!

License

MIT © Phosphor Icons

vue's People

Contributors

dnlsndr avatar hypernova7 avatar maful avatar rektdeckard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vue's Issues

Icons not tree-shakable by other bundlers

Don't know where the other issue went, so I'll create a new one to keep track of this.

It seems that with the current configuration of Rollup, it's not possible to tree shake unused icons when using this library with other bundlers such as Webpack.

Ability to use icons via Name parameter

We want to save the icon names as strings in our db, then use them via a name option, this is not currently possible via importing each icon seperatly.

E.g.

Is this something that could be implemented?

Imported components used with `<component :is="">` ignored in production

I'm using a custom component to render all my icons:

<template>
  <component :is="name" :weight="weight" />
</template>

<script lang="ts">
import { defineComponent } from 'vue'

import {
  PhCaretUp as Up,
} from 'phosphor-vue'

export default defineComponent({
  name: 'Icon',
  props: {
    name: { type: String, required: true },
    weight: { default: 'regular' },
  },
  components: {
    Up,
  },
})
</script>

It's all fine in development, but the production bundle ignores all icons. I've just switched from another icon pack that does not cause this (but the bundle size is huge) and right now this problem is pretty annoying.

I've also tried registering the global component in main.ts, to no avail.

Any suggestions are welcome.

TypeScript errors: "no exported member..."

Hello,

we've got some type errors while importing single icons in vue/nuxt with typescript.
The import looks like this:

<script lang="ts">
import { PhXCircle, PhCalendarBlank, PhClock } from 'phosphor-vue'

And the error in VS Code is:

Module '"phosphor-vue"' has no exported member 'PhXCircle'. Did you mean to use 'import PhXCircle from "phosphor-vue"' instead?ts(2614)

But the result works, with this error?

I found this import statement which i never saw like this before.
https://github.com/phosphor-icons/phosphor-vue/blob/4f28cd2e29ca8350b7a0283e241dac5546a8c631/phosphor-vue.d.ts#L3
I guess what i should do, is to pass the exported components from index.ts through the phoshor.d.ts, but this seems not to be valid in TypeScript.

npm ERR! Could not resolve dependency in Quasar vue

DESCRIPTION

Hi, I just wanted to use phosphor vue for my quasar vue application.
But when I run npm install --save phosphor-vue@next, it gets an error like below.
Does anyone know why? Is it because it doesn't support quasar vue or what? Thankyou.

ERROR LOG

$ npm install phosphor-vue@next
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/vue
npm ERR! peer vue@"^3.2.29" from @quasar/[email protected]
npm ERR! node_modules/@quasar/app
npm ERR! dev @quasar/app@"^3.0.0" from the root project
npm ERR! peer vue@"3.2.37" from @vue/[email protected]
npm ERR! node_modules/@vue/server-renderer
npm ERR! @vue/server-renderer@"3.2.37" from [email protected]
npm ERR! 9 more (emoji-mart-vue-fast, v-money3, vue-gtag, vue-i18n, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! phosphor-vue@"4.4.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/vue
npm ERR! peer vue@"^3.0.0 <3.0.3" from [email protected]
npm ERR! node_modules/phosphor-vue
npm ERR! phosphor-vue@"4.4.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\ASUS\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ASUS\AppData\Local\npm-cache_logs\2022-07-15T02_44_38_791Z-debug-0.log

"Error: EMFILE: too many open files... " when deploying Nuxt 3 app with Phosphor Icons to Netlify

🐛 The bug

When I deploy my Nuxt 3 app which uses the @phosphor-icons/vue package to Netlify, the deployment is successful but when I visit the site, initially, I get an error:

image

After some time, when I revisit the site, I get this error:

image

It works okay in development and I've also tried building the app locally, Nuxt uses the "node-server" option and that works fine.

🛠️ To reproduce

https://stackblitz.com/edit/nuxt-starter-tfqdxc?file=app.vue

🌈 Expected behaviour

The Icons should be displayed in production when deployed to Netlify and not crash the entire app.

ℹ️ Additional context

No response

'/@modules/vue.js' does not provide an export named 'default' when using vitejs

I am trying to use phosphor-vue in a project that is set up with vitejs.

I tried to

//vite.config.js
optimizeDeps: {
    exclude: ['dayjs', 'phosphor-vue']
  }

But I am still getting this.

Uncaught SyntaxError: The requested module '/@modules/vue.js' does not provide an export named 'default'

procedure I followed.

npm init vite-app myapp

npm install phosphor-vue

In my template

//app.vue
<template>
  <div>
    <PhHorse />
    <PhHeart :size="32" color="hotpink" weight="fill" />
    <PhCube />
  </div>
</template>

<script>
  import { PhHorse, PhHeart, PhCube } from "phosphor-vue";
  export default {
    name: "App",
    components: {
      PhHorse,
      PhHeart,
      PhCube
    }
  };
</script>

Update peer dependency version

Hello! Thank you for the nice icons.

I have switched to npm 7 and it installs peer dependencies by default. So when I updated Vue to 3.0.11 I got a conflict with phosphor-vue's peer dependencies:

  "peerDependencies": {
    "vue": "^3.0.0 <3.0.3"
  },

Could you, please, change it to ^3.0.0 and make a new patch release?
Right now I can run npm install only with --legacy-peer-deps (when there is no package-lock.json).

@vue/cli-service: Cannot find module '@/lib/types'

When I try to use phosphor-vue with @vue/cli-service I get the error Cannot find module @/lib/types. To avoid that error, I had to copy the file phosphor-vue/src/lib/types.ts locally. Because in @vue/cli-service the alias @ only points to the local directory src

Webpack error stating no appropriate loaders

Hey there!
I currently use Phosphor Icons for my Nuxt.js website, however I've been receiving this error when trying to load my site:

 ERROR  in ./node_modules/phosphor-vue/dist/phosphor-vue.esm.js                                                                       friendly-errors 12:24:55

Module parse failed: Unexpected token (40:21)                                                                                         friendly-errors 12:24:55
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|         contextWeight
|       } = this;
>       return weight ?? contextWeight;
|     },
| 

It's failing to compile. I've tried uninstalling and re-installing using npm install --save phosphor-vue. I've also tried looking for a solution online, and can't seem to find anything that could point me in the right direction.
Curious if anyone else has experienced this, and knows how to solve it? It's quite cumbersome.

Export PhosphorIcon type

Hi, I'd like to ensure a PhosphorIcon is being passed as a prop, but unfortunately this type isn't exported by phosphor-vue.

What I'd like to do is this:

const props = defineProps<{
  label: string;
  icon: PhosphorIcon;
}>();

And then render with something like this:

    <component
      :is="icon"
      :size="20"
      :width="20"
      :weight="isActive ? 'fill' : 'regular'"
    />

Would exporting the PhosphorIcon type make sense?

Production build imports all icons !

i am only loading the following

import {
  PhLockKeyOpen,
  PhUser,
  PhSun,
  PhMoon,
  PhPlayCircle,
  PhImage,
} from 'phosphor-vue'

import Vue from 'vue'

Vue.component('PhLockKeyOpen', PhLockKeyOpen)
Vue.component('PhUser', PhUser)
Vue.component('PhSun', PhSun)
Vue.component('PhMoon', PhMoon)
Vue.component('PhPlay', PhPlayCircle)
Vue.component('PhImage', PhImage)

the build result creates big javascript file

Code_q7Olh5tvui
msedge_MRLBAUkRV0

`@phosphor-icons/vue/compact` significantly increases the build time

🐛 The bug

Compact bundle significantly increases the build time. That being said, the import cost for the bundle is 3.8M:

Import cost

As mentioned in v2.1.4 changelog compact scope bundles all files in a single file aiming to fix the EMFILE error.

Is there any other way of avoiding Error: EMFILE: too many open files... error as in #35 besides using compact scope?

🛠️ To reproduce

Build screenshot

🌈 Expected behaviour

A proposed solution would be exporting per-file icons as in:

import PhHouse from "@phosphor-icons/vue/icons/PhHouse.vue"

ℹ️ Additional context

No response

Module not found: Error: Default condition should be last one

📚 What are you trying to do?

import { PhCircle,PhTextAa,PhEyeSlash } from "@phosphor-icons/vue";

this line makes me below error. Does not understand what is issue. I have other appas well and all working fine.

Module not found: Error: Default condition should be last one

ERROR in ./src/Student/components/CustomElements/PIcons.vue?vue&type=script&setup=true&lang=js (./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/Student/components/CustomElements/PIcons.vue?vue&type=script&setup=true&lang=js) 3:0-2137
Module not found: Error: Default condition should be last one
 @ ./src/Student/components/CustomElements/PIcons.vue?vue&type=script&setup=true&lang=js 1:0-221 1:0-221 1:222-432 1:222-432
 @ ./src/Student/components/CustomElements/PIcons.vue 2:0-68 3:0-63 3:0-63 6:49-55
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/Student/StudentData.vue?vue&type=script&setup=true&lang=js 8:0-60 106:14-20
 @ ./src/Student/StudentData.vue?vue&type=script&setup=true&lang=js 1:0-214 1:0-214 1:215-418 1:215-418
 @ ./src/Student/StudentData.vue 2:0-73 3:0-68 3:0-68 6:49-55
 @ ./src/router/routes.js 265:15-51
 @ ./src/main.js 12:0-40 113:8-14

🔍 What have you tried?

Tryed reeinstall phosphor with npm , other versions start again and so on. I came from vue 2 to vue 3 and this problem comes.

ℹ️ Additional context

No response

Global import broken

🐛 The bug

With the previous version phosphor-vue, global import was possible using

import { createApp } from 'vue'
import PhosphorVue from 'phosphor-vue'

const app = createApp(App)
app
  .use(PhosphorVue)

app.mount('#app')

With the new version, this is not possible anymore.

🛠️ To reproduce

https://stackblitz.com/edit/vue-dniokx?file=src/main.js

🌈 Expected behaviour

that switching to the new package works straightforward (just like written in the README.md)

ℹ️ Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.