Skip to content

Commit eadb32a

Browse files
authored
Merge pull request #5 from MADE-Apps/feature/assets
Added image and background image components
2 parents a5d2339 + 322a079 commit eadb32a

20 files changed

+13419
-0
lines changed

.github/workflows/made-vue-image.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: made-vue-image
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
branches:
8+
- main
9+
paths:
10+
- made-vue-image/**
11+
- build/**
12+
- .github/workflows/made-vue-image.yml
13+
pull_request:
14+
branches:
15+
- main
16+
paths:
17+
- made-vue-image/**
18+
- build/**
19+
- .github/workflows/made-vue-image.yml
20+
workflow_dispatch:
21+
22+
defaults:
23+
run:
24+
working-directory: made-vue-image
25+
26+
jobs:
27+
build:
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- name: Get source
32+
uses: actions/checkout@v2
33+
34+
- name: Get Build Version
35+
run: |
36+
Import-Module ..\build\GetBuildVersion.psm1
37+
$version = GetBuildVersion -VersionString $Env:GITHUB_REF
38+
echo "BUILD_VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
39+
Write-Host $version
40+
shell: pwsh
41+
42+
- name: Setup node
43+
uses: actions/setup-node@v2
44+
with:
45+
node-version: '16.x'
46+
registry-url: 'https://registry.npmjs.org'
47+
48+
- name: Restore dependencies
49+
run: npm install
50+
51+
- name: Update Version
52+
run: npm version $BUILD_VERSION --no-git-tag-version --allow-same-version
53+
54+
- name: Build
55+
run: npm run build
56+
57+
- name: Copy package.json to dist
58+
run: cp "package.json" "./dist/package.json"
59+
60+
- name: Copy README.md to dist
61+
run: cp "README.md" "./dist/README.md"
62+
63+
- name: Publish
64+
if: startsWith(github.ref, 'refs/tags/v')
65+
working-directory: made-vue-image/dist
66+
run: npm publish
67+
env:
68+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

assets/Logo.afdesign

-5.93 KB
Binary file not shown.

assets/ProjectIcon.png

8.04 KB
Loading

made-vue-image/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<img src="https://github.com/MADE-Apps/MADE-Vue/blob/main/assets/ProjectBanner.png" alt="MADE Vue project banner" />
2+
3+
# MADE Vue - Image
4+
5+
[![License - MIT](https://img.shields.io/badge/License-MIT-yellow)](https://github.com/MADE-Apps/MADE-Vue/blob/main/LICENSE)
6+
[![Build - GitHub Actions](https://github.com/MADE-Apps/MADE-Vue/actions/workflows/made-vue-image.yml/badge.svg)](https://github.com/MADE-Apps/MADE-Vue/actions/workflows/made-vue-image.yml)
7+
[![Source - npmjs](https://img.shields.io/npm/v/made-vue-image)](https://www.npmjs.com/package/made-vue-image)
8+
[![npm](https://img.shields.io/npm/dt/made-vue-image)](https://www.npmjs.com/package/made-vue-image)
9+
10+
A Vue 3 image and background image component, allowing an image to be downloaded while showing a loading indicator, showing a placeholder image if the source image fails to load.
11+
12+
## Usage
13+
14+
To customize the image or background image component, you'll want to import the scss styling:
15+
16+
```
17+
import "made-vue-image/styles.scss";
18+
```
19+
20+
In your main file, you can import the component:
21+
22+
```
23+
import { createApp } from "vue";
24+
import App from "./App.vue";
25+
26+
import Image from "made-vue-image";
27+
28+
const app = createApp(App);
29+
...
30+
app.use(Image);
31+
...
32+
app.mount("#app");
33+
```
34+
35+
You can then reference the image and background image components in your app:
36+
37+
```
38+
<template>
39+
<div>
40+
<m-image
41+
:src="imageSrc"
42+
:alt="imageAlt"
43+
:placeholderSrc="placeholderSrc"
44+
:placeholderAlt="placeholderAlt"
45+
class="my-image mb-3"
46+
/>
47+
48+
<m-image-bg
49+
:src="imageSrc"
50+
:placeholderSrc="placeholderSrc"
51+
class="my-image"
52+
/>
53+
</div>
54+
</template>
55+
56+
<script lang="ts">
57+
import { defineComponent } from "vue";
58+
59+
export default defineComponent({
60+
name: "Page",
61+
data() {
62+
return {
63+
imageSrc: "https://placekitten.com/300/200",
64+
imageAlt: "A cute kitten",
65+
placeholderSrc: "https://via.placeholder.com/300x200/fff.png",
66+
placeholderAlt: "Image placeholder",
67+
};
68+
},
69+
});
70+
</script>
71+
72+
<style>
73+
.mb-3 {
74+
margin-bottom: 1rem;
75+
}
76+
77+
.my-image {
78+
width: 300px;
79+
height: 200px;
80+
}
81+
</style>
82+
```

made-vue-image/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<link rel="shortcut icon" href="/favicon.ico" />
7+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
8+
<title>Image</title>
9+
</head>
10+
11+
<body>
12+
<div id="app"></div>
13+
<script type="module" src="/src/main.ts"></script>
14+
</body>
15+
16+
</html>

0 commit comments

Comments
 (0)