Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codersrank/activity

Package Overview
Dependencies
Maintainers
5
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codersrank/activity

CodersRank activity widget

  • 0.9.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
289
decreased by-4.3%
Maintainers
5
Weekly downloads
 
Created
Source

CodersRank Activity Widget

CodersRank Activity Widget is a web component that allows you easily integrate nice looking activity chart from your CodersRank profile to your personal website:

Install from NPM

Widget script available through NPM:

npm i @codersrank/activity --save

After installation you need to import and register web component:

import CodersRankActivity from '@codersrank/activity';

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

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/activity@x.x.x/codersrank-activity.min.js"></script>

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

Usage

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

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

Widget Attributes

Widget supports following properties as HTML element attributes:

NameTypeDefaultDescription
usernamestringYour CodersRank username
weeksnumber52Amount of weeks to be rendered in chart (max 52).
labelsbooleanfalseDisplay chart labels (months and days of the week)
legendbooleanfalseDisplay legend below the chart
tooltipbooleanfalseEnables tooltip with number of activities per day
stepnumber10Number of activities for division by colors
svg-widthnumber800Render width of chart's SVG element

For example, to enable labels, legend and tooltip:

<codersrank-activity username="YOUR_USERNAME" labels legend tooltip></codersrank-activity>

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
--font-familyOpen Sans, Helvetica Neue, Helvetica, Arial, sans-serif
--label-font-size9px
--label-text-color#999ea4
--legend-font-size12px
--legend-text-color#999ea4
--legend-item-width14px
--legend-item-height14px
--legend-margin1em 0 0 0
--bg-color-0#f6f6f6
--bg-color-1rgba(80, 176, 186, 0.3)
--bg-color-2rgba(80, 176, 186, 0.6)
--bg-color-3rgba(80, 176, 186, 1)
--bg-color-4#24565a
--border-color-0transparent
--border-color-1transparent
--border-color-2transparent
--border-color-3transparent
--border-color-4transparent
--svg-width100%
--svg-heightauto
--preloader-color#72a0a8
--tooltip-font-size14px

For example, to change legend text color to red and font-size to 10px, add this to CSS stylesheet:

codersrank-activity {
  --legend-text-color: red;
  --legend-font-size: 10px;
}

Events

Widget element supports the following events:

NameDescriptionDetail
errorWill be fired on data request errorevent.detail will contain an error object
dataWill be fired right after data request event.detail will contain an object with data and total properties.

total property contains number of total activities

data object contains information about activities by dates

For example:

<codersrank-activity id="activity" ...></codersrank-activity>
function onData(event) {
  const total = event.detail.total;
  console.log(`${total} activities in the last year`);
}
document.querySelector('#activity').addEventListener('data', onData);

Contribution

Yes please! See the contributing guidelines for details.

Licence

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

Keywords

FAQs

Package last updated on 02 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc