Skip to content

Commit

Permalink
add width to badge
Browse files Browse the repository at this point in the history
  • Loading branch information
Engin Diri committed Jul 19, 2020
1 parent 7793db9 commit 08aeb68
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@schwarzit/runs-on-stackit",
"version": "0.0.1",
"version": "0.0.3",
"description": "With the STACKIT-Badge you can mark internal and external websites and applications that run on, are sponsored or supported by STACKIT.",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand All @@ -11,8 +11,7 @@
"collection:main": "dist/collection/index.js",
"unpkg": "dist/runs-on-stackit/runs-on-stackit.js",
"files": [
"dist/",
"loader/"
"dist/"
],
"scripts": {
"build": "stencil build --docs",
Expand Down
2 changes: 2 additions & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export namespace Components {
* To use runs-on-stackit-badge or runson = Runs On badge poweredby = Powered By color badge
*/
"badgeType": "badge" | "ribbon" | "flag";
"badgeWidth": any;
/**
* To use cd instead local assets
*/
Expand Down Expand Up @@ -46,6 +47,7 @@ declare namespace LocalJSX {
* To use runs-on-stackit-badge or runson = Runs On badge poweredby = Powered By color badge
*/
"badgeType"?: "badge" | "ribbon" | "flag";
"badgeWidth"?: any;
/**
* To use cd instead local assets
*/
Expand Down
21 changes: 21 additions & 0 deletions src/components/stackit-badge/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# stackit-badge



<!-- Auto Generated Below -->


## Properties

| Property | Attribute | Description | Type | Default |
| ------------- | -------------- | -------------------------------------------------------------------------------------------- | --------------------------------- | ----------- |
| `badgeColor` | `badge-color` | Define which badge color to use. yellow = yellow color badge petrol = petrol color badge | `"petrol" \| "white" \| "yellow"` | `'petrol'` |
| `badgeType` | `badge-type` | To use runs-on-stackit-badge or runson = Runs On badge poweredby = Powered By color badge | `"badge" \| "flag" \| "ribbon"` | `'badge'` |
| `badgeWidth` | `badge-width` | | `any` | `undefined` |
| `cdn` | `cdn` | To use cd instead local assets | `boolean` | `true` |
| `hostingType` | `hosting-type` | To use runs-on or powered-by badge runson = Runs On badge poweredby = Powered By color badge | `"poweredby" \| "runson"` | `'runson'` |


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
14 changes: 10 additions & 4 deletions src/components/stackit-badge/stackit-badge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Prop, h, getAssetPath} from '@stencil/core';
import {Component, Prop, h, getAssetPath, Host} from '@stencil/core';

@Component({
tag: 'stackit-badge',
Expand Down Expand Up @@ -33,6 +33,8 @@ export class STACKITBadgeComponent {
*/
@Prop() readonly badgeColor: 'petrol' | 'white' | 'yellow' = 'petrol';

@Prop() readonly badgeWidth;

private getBadgeType() {
switch (this.badgeType) {
case 'badge':
Expand Down Expand Up @@ -78,9 +80,13 @@ export class STACKITBadgeComponent {

render() {
return (
<a href="https://stackit.de" title="STACKIT">
<img width={this.badgeType === 'badge' ? "200" : "96"} src={this.getSrc()}/>
</a>
<Host>
<a href="https://stackit.de" title="STACKIT">
<img
width={this.badgeType === 'badge' ? (this.badgeWidth ? this.badgeWidth : "200") : (this.badgeWidth ? this.badgeWidth : "96")}
src={this.getSrc()}/>
</a>
</Host>
);
}
}
5 changes: 5 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ <h2>Badge</h2>
<br>
<br>
<stackit-badge hosting-type="runson" badge-color="yellow"></stackit-badge>
<br>
<br>
<stackit-badge badge-width="50"></stackit-badge>
<stackit-badge badge-width="100"></stackit-badge>
<stackit-badge badge-width="250"></stackit-badge>
</div>
</div>
<br>
Expand Down
3 changes: 1 addition & 2 deletions stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ export const config: Config = {
taskQueue: 'async',
outputTargets: [
{
type: 'dist',
esmLoaderPath: '../loader'
type: 'dist'
},
{
type: 'docs-readme'
Expand Down

0 comments on commit 08aeb68

Please sign in to comment.