npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@trovster/fitness-visualisations

v1.0.1

Published

Two Web Components for fitness visualisations.

Downloads

9

Readme

Fitness Components

This provides two Web Components for fitness visualisations. You can use a fully featured fitness card or just the activity rings on their own. The default activity ring design is inspired by Apple Fitness.

Installation

npm install @trovster/fitness-visualisations --save

Usage

These are Web Components and must be imported before the custom elements can be used. If you are using the fitness card, then you do not need to import the activity ring.

<script type="module">
  import '@trovster/fitness-visualisations/src/FitnessCard.js';
  import '@trovster/fitness-visualisations/src/FitnessRing.js';
</script>

Both the card and ring require the calories, minutes and hours totals and goals. The card has additional optional values. If you include the date, it appears as a header. The steps, distance and flights data appear in the footer section. The distance attribute should be provided in meters. By default, this is converted to miles, but you can change this to kilometres using units="km".

<fitness-card
  date="YYYY-MM-DD"
  units="km | miles"
  steps="0"
  distance="0"
  flights="0"
  calories-total="0"
  calories-goal="0"
  minutes-total="0"
  minutes-goal="0"
  hours-total="0"
  hours-goal="0"
></fitness-card>

<fitness-ring
  calories-total="0"
  calories-goal="0"
  minutes-total="0"
  minutes-goal="0"
  hours-total="0"
  hours-goal="0"
></fitness-ring>

Custom Text

You can provide a custom header by using the named <slot>. You can also change the text for “calories”, “minutes” and “hours”.

<fitness-card>
  <div slot="header">The Custom Header</div>
  <div slot="calories">Move</div>
  <div slot="minutes">Exercise</div>
  <div slot="hours">Stand</div>
</fitness-card>

Replayable

The activity rings animation can be replayed when using the replayable="true" attribute. When the activity rings are clicked, the animation is replayed in reverse, then completed again.

Styling

The typeface and colours of the text and rings can be changed using CSS variables. The --fitness-value controls the colour of the values in the footer.

The colours of the fitness card values are linked to the ring colours, so they can not be configured independently. To change the fitness card colours you must use the CSS variable without the -ring value.

--fitness-font: sans-serif;

--fitness-value: #9ca3af;
--fitness-calories: #fa114f;
--fitness-minutes: #92e82a;
--fitness-hours: #1eeaef;

--fitness-ring-calories: #fa114f;
--fitness-ring-minutes: #92e82a;
--fitness-ring-hours: #1eeaef;

If you provide labels, they can be styled using --fitness-label CSS variable. You can target each label independently by using the appropriate [slot] selector and setting the CSS variable.

fitness-ring [slot="label-calories"] {
    --fitness-label: #B31162;
}
fitness-ring [slot="label-minutes"] {
    --fitness-label: #1FAD8F;
}
fitness-ring [slot="label-hours"] {
    --fitness-label: #1689A0;
}

You can target the styling of sections within the fitness card visualisation using the ::part pseudo-element.

fitness-card::part(header) {}
fitness-card::part(main) {}
fitness-card::part(ring) {}
fitness-card::part(footer) {}

Development

Linting and Formatting

To scan the project for linting and formatting errors, run:

npm run lint

To automatically fix linting and formatting errors, run:

npm run format

Local Demo with web-dev-server

To start a local development server that serves the basic demo located in docs/index.html, run:

npm start

Tooling Configs

For most of the tools, the configuration is in the package.json to minimize the amount of files in your project.

If you customize the configuration a lot, you can consider moving them to individual files.