Repository: robcresswell/vue-material-design-icons
Branch: dev
Commit: eb73e7d6c8c9
Files: 18
Total size: 23.9 KB
Directory structure:
gitextract_5c8v8d18/
├── .babelrc
├── .circleci/
│ └── config.yml
├── .dependabot/
│ └── config.yml
├── .gitignore
├── .npmrc
├── .nvmrc
├── .prettierrc.json
├── .releaserc
├── CHANGELOG.md
├── LICENSE
├── README.md
├── __tests__/
│ ├── __snapshots__/
│ │ └── icon.js.snap
│ └── icon.js
├── build.ts
├── jest.config.js
├── package.json
├── styles.css
└── tsconfig.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .babelrc
================================================
{
"presets": [["@babel/preset-env", {"targets": { "node": "current" }}]]
}
================================================
FILE: .circleci/config.yml
================================================
version: 2.1
defaults: &defaults
working_directory: ~/ci
resource_class: small
docker:
- image: cimg/node:lts
commands:
install_deps:
description: Install dependencies
steps:
- checkout
- run: npm ci
jobs:
test:
<<: *defaults
steps:
- install_deps
- run: npm run build
- run: ./node_modules/.bin/jest --runInBand --ci
- store_test_results:
path: reports
release:
<<: *defaults
steps:
- install_deps
- run: npm run build
- run: npx semantic-release
workflows:
version: 2
test_and_release:
jobs:
- test
- release:
requires:
- test
================================================
FILE: .dependabot/config.yml
================================================
version: 1
update_configs:
- package_manager: "javascript"
directory: "/"
update_schedule: "live"
default_reviewers:
- "robcresswell"
default_assignees:
- "robcresswell"
version_requirement_updates: "increase_versions"
commit_message:
prefix: "feat"
prefix_development: "chore"
include_scope: true
================================================
FILE: .gitignore
================================================
*.swp
.DS_Store
node_modules/
*.log
*.tgz
dist/
coverage/
reports/
================================================
FILE: .npmrc
================================================
audit=false
fund=false
================================================
FILE: .nvmrc
================================================
18
================================================
FILE: .prettierrc.json
================================================
{
"arrowParens": "always",
"trailingComma": "all",
"singleQuote": true,
"htmlWhitespaceSensitivity": "ignore"
}
================================================
FILE: .releaserc
================================================
{
"branches": "dev",
"tagFormat": "${version}",
"pkgRoot": "dist/",
"plugins": [
"@semantic-release/commit-analyzer",
[
"@semantic-release/github",
{
"successComment": false
}
],
"@semantic-release/npm",
"@semantic-release/release-notes-generator"
]
}
================================================
FILE: CHANGELOG.md
================================================
# Change Log
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
# [3.2.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/3.1.0...3.2.0) (2019-04-24)
### Features
* New icons (mdi dep update) ([0382799](https://gitlab.com/robcresswell/vue-material-design-icons/commit/0382799))
# [3.1.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/3.0.0...3.1.0) (2019-03-04)
### Features
* New icons & dependency upgrades ([03b3de1](https://gitlab.com/robcresswell/vue-material-design-icons/commit/03b3de1))
# [3.0.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/2.8.0...3.0.0) (2019-02-03)
### Bug Fixes
* delegate click events ([84f5c00](https://gitlab.com/robcresswell/vue-material-design-icons/commit/84f5c00))
### BREAKING CHANGES
* This is an extremely cautious breaking change, mostly
because an icon library should definitely not cause breakages.
Previously the library required manually added click handlers, which was
fine when declaring the icons inline but not helpful when using them
programmatically with libraries like Vuetify.
# [2.8.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/2.7.0...2.8.0) (2019-02-03)
### Features
* Add ability to change size via a prop ([d4e76ed](https://gitlab.com/robcresswell/vue-material-design-icons/commit/d4e76ed))
# [2.7.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/2.6.0...2.7.0) (2019-02-03)
### Features
* Add more icons ([05f3f45](https://gitlab.com/robcresswell/vue-material-design-icons/commit/05f3f45))
# [2.6.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/2.5.0...2.6.0) (2019-01-03)
### Features
* Add new icons (update [@mdi](https://gitlab.com/mdi)/js) ([285726e](https://gitlab.com/robcresswell/vue-material-design-icons/commit/285726e))
# [2.5.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/2.4.0...2.5.0) (2018-12-23)
### Bug Fixes
* A basic size instructions to README ([66bf350](https://gitlab.com/robcresswell/vue-material-design-icons/commit/66bf350))
* IE11 tooltip support ([3966a2d](https://gitlab.com/robcresswell/vue-material-design-icons/commit/3966a2d))
### Features
* Add new icons (update [@mdi](https://gitlab.com/mdi)/js) ([23f7868](https://gitlab.com/robcresswell/vue-material-design-icons/commit/23f7868))
# [2.4.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/2.3.0...2.4.0) (2018-11-04)
### Features
* New icons (updated mdi) ([236124c](https://gitlab.com/robcresswell/vue-material-design-icons/commit/236124c))
# [2.3.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/2.1.1...2.3.0) (2018-10-10)
### Features
* Update to newest version of mdi ([208c0ab](https://gitlab.com/robcresswell/vue-material-design-icons/commit/208c0ab))
# [2.2.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/2.1.1...2.2.0) (2018-10-10)
### Features
* Update to newest version of mdi ([208c0ab](https://gitlab.com/robcresswell/vue-material-design-icons/commit/208c0ab))
## [2.1.1](https://gitlab.com/robcresswell/vue-material-design-icons/compare/2.1.0...2.1.1) (2018-09-03)
### Bug Fixes
* Fix broken publish ([c7fb649](https://gitlab.com/robcresswell/vue-material-design-icons/commit/c7fb649))
# [2.1.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/2.0.0...2.1.0) (2018-09-03)
### Features
* Update mdi (new icons) ([8e2dc27](https://gitlab.com/robcresswell/vue-material-design-icons/commit/8e2dc27))
# [2.0.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/1.6.0...2.0.0) (2018-08-18)
### Features
* Upgrade MDI & match vue styleguide ([cfdf17e](https://gitlab.com/robcresswell/vue-material-design-icons/commit/cfdf17e)), closes [#1](https://gitlab.com/robcresswell/vue-material-design-icons/issues/1) [#2](https://gitlab.com/robcresswell/vue-material-design-icons/issues/2)
### BREAKING CHANGES
* Match the component names to the structure recommended
by the Vue style guide. This means all files now begin with a capital
letter, i.e. "android.vue" is now "Android.vue", and the component
names are Pascal-cased instead of camel-cased. i.e.
"CheckboxMarkedCircle" instead of "checkbox-marked-circle".
Other changes include:
- Async build script, to make it a little faster. Also refactored to
use the new @mdi/svg repo, so some of the build hacks can go away.
- Added some testing and snapshots, to make upgrades quicker to verify.
- Updated to the lastest version of MDI for more icons.
- Updated the LICENSE for 2018
- Added .nvmrc
- Fairly unimportant, but the generated .vue files now pass all the
rules on the Vue style guide; this should make them a little more
consistent and easier to read for those familiar with Vue.
# [1.6.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/1.5.1...1.6.0) (2018-07-22)
### Features
* Update mdi to 2.5.94 ([6fefdbe](https://gitlab.com/robcresswell/vue-material-design-icons/commit/6fefdbe))
## [1.5.1](https://gitlab.com/robcresswell/vue-material-design-icons/compare/1.5.0...1.5.1) (2018-05-28)
### Bug Fixes
* Fix release script ([4a7b3df](https://gitlab.com/robcresswell/vue-material-design-icons/commit/4a7b3df))
# [1.5.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/1.4.0...1.5.0) (2018-05-28)
### Features
* Update to latest version of material design icons ([57d4857](https://gitlab.com/robcresswell/vue-material-design-icons/commit/57d4857))
# [1.4.0](https://gitlab.com/robcresswell/vue-material-design-icons/compare/1.3.0...1.4.0) (2018-04-19)
### Bug Fixes
* Make standard-version tag format match existing tags ([13ca214](https://gitlab.com/robcresswell/vue-material-design-icons/commit/13ca214))
* Remove CHANGELOG header for standard-version ([cd28237](https://gitlab.com/robcresswell/vue-material-design-icons/commit/cd28237))
### Features
* Add standard-version for easier CHANGELOG creation ([826b17d](https://gitlab.com/robcresswell/vue-material-design-icons/commit/826b17d))
* Upgrade the build tooling ([52495c0](https://gitlab.com/robcresswell/vue-material-design-icons/commit/52495c0))
* Use [@mdi](https://gitlab.com/mdi)/svg from npm instead of git ([7542255](https://gitlab.com/robcresswell/vue-material-design-icons/commit/7542255))
## [1.3.0] - 2018-04-02
- Updated to use icons from v2.2.43 of [MaterialDesign]
(https://github.com/Templarian/MaterialDesign)
## [1.2.1] - 2018-03-08
### Changed
- Updated `styles.css` so that it was actually valid CSS. Previously it was
SCSS. *facepalm*
## [1.2.0] - 2018-03-07
### Changed
- Updated the `MaterialDesign-SVG` dependency, adding many new icons
- Moved the internal tooling to Yarn
- Slightly changed the repo description wording
## [1.1.0] - 2018-02-07
### Added
- Added a `fillColor` prop that lets you set a fill colour via component prop
rather than CSS. Thanks to [Sagar Subedi](https://gitlab.com/sagarSubedi) for
the change.
### Changed
- Modified the base template to set a default title via prop definition, instead
of using a computed prop. This shouldn't make any outward difference, but makes
the code a little cleaner.
### Fixed
- Improved the package.json scripts so that they work from a fresh clone
of the repo.
## [1.0.0] - 2018-01-09
### Added
- Added a "Props" section to the README
- Added a `decorative` prop that toggles whether icons are hidden from
screen readers. This is false by default (i.e. icons are shown to screen
readers)
### Changed
- Changed the icon IDs to classes (i.e. `#android-icon` is now `.android-icon`)
to avoid invalid HTML when using the same icon multiple times in one page
- Changed the `aria-labelled-by` attribute to an `aria-label` attribute to
avoid using duplicate IDs
- Changed the wrapping element from a `
` to a ``
## [0.8.2] - 2017-12-13
### Changed
- Small improvements to the README, such as extra tips, and formatting fixes
## [0.8.1] - 2017-12-11
### Fixed
- Fixed the excessive padding around the `title`
## [0.8.0] - 2017-12-11
### Changed
- Updated the `MaterialDesign-SVG` dependency, adding many new icons
- Updated to a new version of `mustache`
- Added credit referencing the `mdi-vue` library
## [0.7.1] - 2017-08-06
### Added
- Added a "Tips" section to the `README`
## [0.7.0] - 2017-08-06
### Added
- Added a `title` prop to the icons, allowing the title to be customised. The
default is still `-icon`, e.g. `android-icon`
### Changed
- Changed the title ID from `-title` to `-icon-title`
## [0.6.3] - 2017-07-27
### Fixed
- Added a note about finding the icon list to the `README`
## [0.6.2] - 2017-07-27
### Fixed
- Made the icon source more explicit in the `README`
## [0.6.1] - 2017-07-25
### Fixed
- Added the missing `CHANGELOG` entry for 0.6.0
## [0.6.0] - 2017-07-25
### Changed
- Changed from the
[MaterialDesign](https://github.com/Templarian/MaterialDesign) repo to
[MaterialDesign-SVG](https://github.com/Templarian/MaterialDesign-SVG) repo
to take advantage of the smaller repo and compressed paths. Overall, this
reduces the size of this repo and its distributed icons. Yay!
## [0.5.0] - 2017-07-25
### Changed
- Updated the `README` to make install steps clearer and added additional
credits
- Small fixes to the `CHANGELOG` formatting
## [0.4.0] - 2017-07-25
### Changed
- The CSS is no longer included in each component by default. It can be
optionally added by including `vue-material-design-icons/styles.css`
- `README` updated to include adding the CSS
## [0.3.1] - 2017-07-24
### Changed
- Updated the package.json keywords
- Small fixes to `README` and `CHANGELOG`
## [0.3.0] - 2017-07-24
### Added
- Added a `CHANGELOG` to better track updates
- Added `LICENSE` to distributed package
### Changed
- Split out CSS from the template file, to reduce the overall package size
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2018 Rob Cresswell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# Vue Material Design Icon Components
This library is a collection of Vue single-file components to render Material
Design Icons, sourced from the
[MaterialDesign project](https://github.com/Templarian/MaterialDesign 'MaterialDesign Github page').
It also includes some CSS that helps make the scaling of the icons a little
easier.
## Getting started
1. Install the package
```console
yarn add vue-material-design-icons
```
**OR**
```console
npm i vue-material-design-icons
```
2. Import the icon, and declare it as a local component:
```javascript
import MenuIcon from 'vue-material-design-icons/Menu.vue';
components: {
MenuIcon;
}
```
**OR**
Declare it as a global component:
```javascript
import MenuIcon from 'vue-material-design-icons/Menu.vue';
Vue.component('menu-icon', MenuIcon);
```
> **Note** Icon files are pascal cased, e.g. `CheckboxMarkedCircle.vue`, and
> their default name has `Icon` appended e.g. `CheckboxMarkedCircleIcon`.
3. Then use it in your template code!
```html
```
4. **Optional** Add the included stylesheet. This few lines of CSS will cause
the icons to scale with any surrounding text, which can be helpful when you
primarily style with CSS. Note that if you intend to handle sizing with the
`size` prop, you probably don't want to use this as it may conflict.
```javascript
import 'vue-material-design-icons/styles.css';
```
## Props
- `title` - This changes the hover tooltip as well as the title shown to screen
readers. For accessibility purposes, if a `title` is not provided, then the
icon is hidden from screen readers. This is to force developers to use
meaningful titles for their icon usage.
Example:
```html
```
- `fillColor` - This property allows you to set the fill colour of an icon via
JS instead of requiring CSS changes. Note that any CSS values, such as
`fill: currentColor;` provided by the optional CSS file, may override colours
set with this prop.
Example:
```html
```
- `size` - This property overrides the `width` and `height` attributes on the
SVG. The default is `24`.
Example:
```html
```
## Icons
A list of the icons can be found at the
[Material Design Icons website](https://materialdesignicons.com/ 'Material Design Icons website'). The icons packaged here are pascal cased
versions of the names displayed on the website, to match the
[Vue Style Guide](https://vuejs.org/v2/style-guide/). For example, the icon
named `ultra-high-definition` would be imported as
`"vue-material-design-icons/UltraHighDefinition.vue"`.
## Tips
- Use `resolve` in your Webpack config to clean up the imports:
```javascript
resolve: {
alias : {
"icons": path.resolve(__dirname, "node_modules/vue-material-design-icons")
},
extensions: [
".vue"
]
}
```
This will give you much shorter and more readable imports, like
`import Android from "icons/Android"`, rather than
`import Android from "vue-material-design-icons/Android.vue"`. Much better!
- If you want custom sizing, add your own css to adjust the height and width of the icons
```css
.material-design-icon.icon-2x {
height: 2em;
width: 2em;
}
.material-design-icon.icon-2x > .material-design-icon__svg {
height: 2em;
width: 2em;
}
```
Then add your size class
```html
```
While I recommend using CSS for styling, you can also pass in a `size` prop,
detailed in the `Props` section above.
## Credits
[Austin Andrews / Templarian](https://github.com/Templarian "Templarian's GitHub profile") for
the [MaterialDesign](https://github.com/Templarian/MaterialDesign 'MaterialDesign Github page')
project. This supplies the SVG icons for this project, which are packaged as
Vue single file components.
[Elliot Dahl](http://www.elliotdahl.com/ "Elliot Dahl's website") for
[this article on prototypr.io](https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4 'Align SVG Icons to Text and Say Goodbye to Font Icons'). This is where the
recommended CSS comes from.
[Attila Max Ruf / therufa](https://github.com/therufa "therufa's GitHub Profile")
for the [mdi-vue](https://github.com/therufa/mdi-vue 'mdi-vue') library which
inspired this one. It also produces single file components from material
design icons.
================================================
FILE: __tests__/__snapshots__/icon.js.snap
================================================
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Icon renders an icon 1`] = ``;
================================================
FILE: __tests__/icon.js
================================================
import { mount } from '@vue/test-utils';
import AndroidIcon from '../dist/Android';
const WrappedIcon = {
components: {
AndroidIcon,
},
render(h) {
return h(AndroidIcon, {
attrs: this.$attrs,
listeners: this.$listeners,
});
},
};
describe('Icon', () => {
let icon;
beforeEach(() => {
icon = mount(WrappedIcon);
});
it('accepts a "title" property', async () => {
expect(icon.attributes()['aria-label']).toBeUndefined();
await icon.setProps({ title: 'foo' });
expect(icon.attributes()['aria-label']).toEqual('foo');
});
it('accepts a "fillColor" property', async () => {
const svg = icon.find('.material-design-icon__svg');
expect(svg.attributes()['fill']).toEqual('currentColor');
await icon.setProps({ fillColor: '#FF0000' });
expect(svg.attributes()['fill']).toEqual('#FF0000');
});
it('renders an icon', () => {
expect(icon).toMatchSnapshot();
});
it('listens to a click event', async () => {
const clickListener = jest.fn();
const iconWithEvent = mount({
name: 'IconWithEvent',
components: { AndroidIcon },
template: `
`,
methods: {
clickListener,
},
});
await iconWithEvent.trigger('click');
expect(clickListener).toBeCalled();
});
});
================================================
FILE: build.ts
================================================
#!/usr/bin/env -S node -r ts-node/register/transpile-only
// Imports
import { mkdir, writeFile } from 'fs/promises';
import path from 'path';
import pMap from 'p-map';
import * as icons from '@mdi/js/commonjs/mdi.js';
import { existsSync } from 'fs';
const dist = path.resolve(__dirname, 'dist');
function renderTemplate(title: string, svgPathData: string, name: string) {
return `
`;
}
function getTemplateData(id: string) {
const splitID = id.split(/(?=[A-Z])/).slice(1);
const name = splitID.join('');
// This is a hacky way to remove the 'mdi' prefix, so "mdiAndroid" becomes
// "android", for example
const title = splitID.join('-').toLowerCase();
return {
name,
title,
svgPathData: icons[id],
};
}
async function build() {
const iconIDs = Object.keys(icons);
if (!existsSync(dist)) {
await mkdir(dist);
}
const templateData = iconIDs.map(getTemplateData);
// Batch process promises to avoid overloading memory
await pMap(
templateData,
async ({ name, title, svgPathData }) => {
const component = renderTemplate(title, svgPathData, name);
const filename = `${name}.vue`;
return writeFile(path.resolve(dist, filename), component);
},
{ concurrency: 20 },
);
}
build().catch((err: unknown) => {
console.log(err);
});
================================================
FILE: jest.config.js
================================================
module.exports = {
verbose: true,
testEnvironment: 'jsdom',
moduleFileExtensions: ['js', 'vue'],
transform: {
'^.+\\.vue$': 'vue-jest',
'^.+\\.js$': '/node_modules/babel-jest',
},
snapshotSerializers: ['/node_modules/jest-serializer-vue'],
};
================================================
FILE: package.json
================================================
{
"name": "vue-material-design-icons",
"version": "3.2.0",
"author": "Rob Cresswell ",
"license": "MIT",
"description": "A collection of material design icons as Vue single file components",
"repository": "github:robcresswell/vue-material-design-icons",
"keywords": [
"vue",
"material design icons",
"mdi",
"icons",
"material",
"icon",
"svg",
"vue.js",
"material design"
],
"devDependencies": {
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@mdi/js": "7.4.47",
"@types/node": "^18.11.18",
"@vue/test-utils": "1.2.2",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^29.4.1",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"jest-serializer-vue": "2.0.2",
"p-map": "^4.0.0",
"prettier": "^2.8.3",
"regenerator-runtime": "^0.13.11",
"ts-node": "^10.9.1",
"typescript": "^4.9.5",
"vue": "^2.7.14",
"vue-jest": "^3.0.7",
"vue-template-compiler": "^2.7.14"
},
"homepage": "https://github.com/robcresswell/vue-material-design-icons",
"bugs": {
"url": "https://github.com/robcresswell/vue-material-design-icons/issues"
},
"scripts": {
"prebuild": "rm -rf dist/",
"build": "./build.ts",
"postbuild": "cp styles.css package.json README.md dist/",
"format": "prettier --write **/*.{js,vue}",
"test": "jest"
}
}
================================================
FILE: styles.css
================================================
.material-design-icon {
display: inline-flex;
align-self: center;
position: relative;
height: 1em;
width: 1em;
}
.material-design-icon > .material-design-icon__svg {
height: 1em;
width: 1em;
fill: currentColor;
position: absolute;
bottom: -0.125em;
}
================================================
FILE: tsconfig.json
================================================
{
"compilerOptions": {
"target": "ES2021",
"module": "commonjs",
"pretty": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"importsNotUsedAsValues": "error",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true
}
}