GithubHelp home page GithubHelp logo

codersrank-org / summary-widget Goto Github PK

View Code? Open in Web Editor NEW
22.0 4.0 12.0 776 KB

Integrate your CodersRank profile summary to your personal website

Home Page: https://codersrank.io

License: MIT License

JavaScript 70.38% HTML 12.71% SCSS 16.91%
profile portfolio codersrank-widget webcomponents cv codersrank

summary-widget's Introduction

Codersrank Summary Widget

Codersrank Summary Widget is a web component that allows you integrate widget with your CodersRank profile summary to your personal website:

Install from NPM

Widget script available through NPM:

npm i @codersrank/summary --save

After installation you need to import and register web component:

import CodersrankSummary from '@codersrank/summary';

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

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/[email protected]/codersrank-summary.min.js"></script>

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

Usage

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

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

Widget Attributes

Widget supports following properties as HTML element attributes:

Name Type Default Description
username string Your CodersRank username
layout string 'auto' Defines the layout of the widget badges. Can be auto, vertical or horizontal. If auto (by default) it will use horizontal layout if it has enough space.
badges number 3 Number (from 0 to 3) of highlighted badges to display.
show-avatar boolean true Defines whether to show avatar or not
show-header boolean true Defines whether to show widget header or not
min-width number 300 Widget minimum width for auto layout to change widget layout from horizontal to vertical
badge-min-width number 100 Badge minimal width to change badge inner layout from horizontal to vertical layout
branding boolean true Displays "Powered by CodersRank" link

For example:

<codersrank-summary username="YOUR_USERNAME" layout="vertical"></codersrank-summary>

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:

Property Value
--bg-color #edf1f3
--border none
--border-radius 4px
--header-padding 8px
--header-bg-color #72a0a8
--header-text-color #fff
--avatar-size 80px
--name-font-size inherit
--name-font-weight bold
--rank-font-size inherit
--preloader-color #72a0a8
--badges-padding 8px
--badge-border-radius 4px
--badge-bg-color #fff
--badge-box-shadow 0px 1px 2px rgba(23, 36, 50, 0.3)
--badge-border none
--badge-margin 8px
--badge-padding 4px
--badge-text-color #000
--badge-rank-font-size 0.85em
--badge-rank-font-weight bold
--badge-icon-size 24px
--badge-technology-font-weight 600
--badge-technology-font-size inherit
--badge-technology-font-weight 600
--badge-technology-font-size 12px
--badge-location-font-size 0.85em
--badge-location-font-weight normal
--branding-text-color inherit

For example, to change header background color to white and name font-size to 20px, add this to CSS stylesheet:

codersrank-summary {
  --header-bg-color: #fff;
  --name-font-size: 20px;
}

Use As Image

It is also possible to insert Summary 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=summary&username=YOUR_USERNAME

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

Name Type Default Description
width number 480 Width 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
style string style attribute value (here you can specify all CSS variables)

For example:

<img
  src="https://cr-ss-service.azurewebsites.net/api/ScreenShot?widget=summary&username=YOUR_USERNAME&badges=2&show-avatar=false&style=--header-bg-color:%23000;--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.

summary-widget's People

Contributors

alimgiray avatar fwolfst avatar nolimits4web avatar peti2001 avatar

Stargazers

 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

summary-widget's Issues

Failed to execute 'define' on 'CustomElementRegistry

When I try to use any CodersRank widget in app with js built by webpack, I get following error:

app.js:5132 Uncaught TypeError: Failed to execute 'define' on 'CustomElementRegistry': parameter 2 is not of type 'Function'.
    at Module../resources/js/app.js (app.js:5132)
    at __webpack_require__ (app.js:52999)
    ....

Surprisingly, widgets (mostly) work, but due to code errors caused by this other stuff (like Vue components) doesn't work.

How can I get around it?

Full code can be seen here:
https://github.com/apsg/gackowski.edu.pl/blob/main/resources/js/app.js

widget with screen shot summary does not work for GitHub Readme

The widget using the link below does not work for GitHub README and it doesnt work from browser:

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

I tried working with issue #5 and the solution for the the issue doesnt work either - neither does caching as I do not control request headers, I just want to use in the README.

How can I make it work in a basic implementation using my username?

Widget doesn't work as an image

Feature request: Show badges on user selected languages, not on the highlighted 3.

Let the user decide which badges to show. Displaying only the highlighted 3 badge makes the widget not very informative.

Proposal:

  1. Default behaviour = display the highlighted badges.
  2. Allow the user to show all the badges.
  3. Allow the user to choose arbitrarily which badges to show. This I suppose would need a list of languages as a parameter.
  4. Allow the user, if show-all-badges chosen, to hide a list of badges.

I may help to implement this if someone gives me a hand initially to understand how the codebase/project is structured/intended. Thank you.

Error Fetching Resource for widget

<img
  src="https://cr-ss-service.azurewebsites.net/api/ScreenShot?widget=summary&username=YOUR_USERNAME&badges=2&show-avatar=false&style=--header-bg-color:%23000;--border-radius:10px"
/>

is no longer working and the Error Fetching Resource pops up

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.