Skip to main content

Periodic table with responsive layout

Project description

Periodic table

Periodic table with responsive layout.

Demo

netbek.github.io/periodic-table

Integration

Install the package:

npm install @netbek/periodic-table

Create a Sass file:

@import 'node_modules/@netbek/periodic-table/src/css/mixins';

// Define vars that should override defaults
$nb-periodic-table-cell-bg:                       #eee;
$nb-periodic-table-cell-border:                   #ccc;

// Load default vars
@import 'node_modules/@netbek/periodic-table/src/css/variables';

// Mobile-first layout
@include nb-periodic-table-base;
@include nb-periodic-table-color;
@include nb-periodic-table-size;

// Wide breakpoint layout
@media (min-width: 82em) {
  @include nb-periodic-table-color('category');
  @include nb-periodic-table-size('wide');
}

Create a Nunjucks template:

{%- from "path/to/node_modules/@netbek/periodic-table/nunjucks/macros/nb_pt_legend.njk" import nb_pt_legend %}
{%- from "path/to/node_modules/@netbek/periodic-table/nunjucks/macros/nb_pt_table_18.njk" import nb_pt_table_18 %}
<html>
  <body>
    {% set element_columns = {
        atomic_number: 'Atomic number',
        symbol: 'Symbol',
        name: 'Name',
        atomic_mass: 'Atomic mass',
        electronegativity: 'Electronegativity'
    } %}
    {{ nb_pt_legend(elements, categories, element_columns) }}
    {{ nb_pt_table_18(elements, groups) }}
  </body>
</html>

Render the Nunjucks template:

import nunjucks from 'nunjucks';
import periodicTable from '@netbek/periodic-table';

async function render() {
  const categories = await periodicTable.loadCategories();
  const elements = await periodicTable.loadElements();
  const groups = await periodicTable.loadGroups();

  const data = {
    categories,
    elements,
    groups
  };

  return nunjucks.render('path/to/template.njk', data);
}

render();

Development: Installation

  1. Install Node 22.x:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    source ~/.bashrc
    nvm install 22
    nvm use 22
    
  2. Install uv:

    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  3. Create .pypirc:

    cp example.pypirc .pypirc
    
  4. Enter a PyPI API token as the password in .pypirc.

  5. Install Node and Python dependencies:

    npm ci
    uv sync
    

Development: Usage

Automatically build and refresh browser during development:

gulp livereload

Build the Python distribution package:

npm run build-dist

Publish the Node and Python distribution packages:

npm run publish-dist

Feature ideas

  • Group and period axes
  • Color by group or block; different palettes (mendeleevapp)

Credit

Data from mendeleev (MIT License)

License

Copyright (c) 2016 Hein Bekker. Licensed under the GNU Affero General Public License, version 3.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netbek_periodic_table-0.2.3.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netbek_periodic_table-0.2.3-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file netbek_periodic_table-0.2.3.tar.gz.

File metadata

  • Download URL: netbek_periodic_table-0.2.3.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for netbek_periodic_table-0.2.3.tar.gz
Algorithm Hash digest
SHA256 60af22c70438e07f60234657cba9f7ceb1f1793a6c45185f810a476760e7f953
MD5 35d04368c003596ece14016b6ebe7513
BLAKE2b-256 2847d2419115c6cad1b7ceb9147bc968b8927ee513f62cbc8e13c8a735f517f9

See more details on using hashes here.

File details

Details for the file netbek_periodic_table-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for netbek_periodic_table-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f71972771d72a182cc6cdda44b19657188c1efd693c8b78bf090c4270388df76
MD5 e1d00c2edc6c8fd7d3461799f6699242
BLAKE2b-256 ffd23fbdcf13675abbc914fd5b4af720f7f935aca47b00c1f56a3f55db8c3fb6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page