0.9.10 • Published 3 years ago

@codersrank/portfolio v0.9.10

Weekly downloads
114
License
MIT
Repository
github
Last release
3 years ago

Codersrank Portfolio Widget

Codersrank Portfolio Widget is a web component that allows you easily integrate portfolio information from your CodersRank profile to your personal website:

Install from NPM

Widget script available through NPM:

npm i @codersrank/portfolio --save

After installation you need to import and register web component:

import CodersrankPortfolio from '@codersrank/portfolio';

// register web component as <codersrank-portfolio> element
window.customElements.define('codersrank-portfolio', CodersrankPortfolio);

Install from CDN

Widget can also be downloaded or linked directly from CDN:

<!-- replace x.x.x with actual version -->
<script src="https://unpkg.com/@codersrank/portfolio@x.x.x/codersrank-portfolio.min.js"></script>

In this case it is not required to register web component, it is already registered as <codersrank-portfolio> element.

Usage

As it is a web component the usage is pretty simple, just add widget HTML tag with your CodersRank username

<codersrank-portfolio username="YOUR_USERNAME"></codersrank-portfolio>

Widget Attributes

Widget supports following properties as HTML element attributes:

NameTypeDefaultDescription
usernamestringYour CodersRank username
max-itemsnumberLimit number of portfolio items to display
gridbooleanfalseEnables grid layout. Number of columns is configurable with --grid-columns CSS variable
logosbooleantrueDefines whether to show portfolio logos/image or not
datesbooleantrueDefines whether to show portfolio item dates or not
titlebooleantrueDefines whether to show portfolio item title or not
descriptionbooleantrueDefines whether to show portfolio item description or not
companybooleantrueDefines whether to show portfolio item company name or not
skillsbooleantrueDefines whether to show portfolio skills or not
linksbooleantrueDefines whether to show portfolio demo and source links or not
brandingbooleantrueDisplays "Powered by CodersRank" link

For example:

<codersrank-portfolio username="YOUR_USERNAME" logos></codersrank-portfolio>

Styling

It is possible to customize widget colors with CSS Custom Properties (CSS Variables) by setting them directly on the widget element with style attribute or in CSS.

There are following CSS Custom Properties are available:

PropertyValue
--preloader-color#72a0a8
--item-spacing2em
--item-border-radius0px
--item-bordernone
--item-padding0px
--item-bg-colortransparent
--grid-columns1
--logo-size48px
--logo-margin16px
--title-font-size1.15em
--title-font-weightbold
--title-text-colorinherit
--title-opacity1
--location-text-colorinherit
--location-opacity0.55
--location-font-sizeinherit
--location-font-weightinherit
--date-text-colorinherit
--date-opacity0.55
--date-font-sizeinherit
--date-font-weightinherit
--company-text-colorinherit
--company-opacity0.55
--company-font-sizeinherit
--company-font-weightinherit
--description-font-sizeinherit
--description-font-weightinherit
--description-text-colorinherit
--description-opacity1
--tag-bordernone
--tag-star-color#ff9900
--tag-bg-colorrgba(0, 0, 100, 0.075)
--tag-font-size0.85em
--tag-font-weightbold
--tag-padding0.35em 0.57em
--tag-margin0.28em
--tag-border-radius4px
--tag-text-colorinherit
--link-margin0.28em
--link-font-size0.85em
--link-font-weight600
--link-text-color#72a0a8
--link-opacity1
--link-text-decorationnone
--link-text-transformuppercase
--link-bordernone
--link-border-radius4px
--link-bg-colortransparent
--link-padding2px 4px
--link-hover-bg-colorrgba(114, 160, 168, 0.15)
--link-hover-text-color-
--link-hover-opacity-
--link-hover-text-decoration-
--link-hover-border-
--link-hover-bg-color-
--link-active-text-color-
--link-active-opacity-
--link-active-text-decoration-
--link-active-border-
--link-active-bg-color-
--branding-text-colorinherit

For example, to change portfolio title color to purple and font-size to 20px, add this to CSS stylesheet:

codersrank-portfolio {
  --title-text-color: purple;
  --title-font-size: 20px;
}

Use As Image

It is also possible to insert Portfolio widget as an image. It is useful in places where you can't integrate web component, or for example on your GitHub profile README.md page.

Image URL is the following:

https://cr-ss-service.azurewebsites.net/api/ScreenShot?widget=portfolio&username=YOUR_USERNAME

It accepts all widget attributes as query string parameters, plus one extra parameter:

NameTypeDefaultDescription
widthnumber800Width of widget element (generated image). Note that generated image has @2x pixel density, so the PNG image will be actually generated in @2x size from the one specified here
stylestringstyle attribute value (here you can specify all CSS variables)

For example:

<img
  src="https://cr-ss-service.azurewebsites.net/api/ScreenShot?widget=portfolio&username=YOUR_USERNAME&max-items=2&dates=false&style=--item-bg-color:%23f00;--item-border-radius:10px"
/>

Note that you need to URL Encode some of the characters, for example # should be %23 and #ff0 color should be specified as %23ff0 in query.

Contribution

Yes please! See the contributing guidelines for details.

Licence

This project is licensed under the terms of the MIT license.