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 Nix:

    sh <(curl -L https://nixos.org/nix/install) --daemon
    
  2. Configure Nix. Edit /etc/nix/nix.conf (for a multi-user installation) or ~/.config/nix/nix.conf (for a single-user installation) to include the following lines:

    experimental-features = nix-command flakes
    trusted-users = root <USER>
    

    Replace <USER> with your username on your computer.

  3. Install direnv:

    sudo apt install direnv
    
  4. Enable direnv in your shell by adding a line to your shell configuration file.

    For Bash, edit ~/.bashrc:

    eval "$(direnv hook bash)"
    
  5. Allow .envrc:

    direnv allow
    
  6. Enter a PyPI API token as the password in .pypirc.

Development: Usage

Automatically build and refresh browser during development:

gulp livereload

Build and publish the JavaScript and Python distribution packages:

make bump-version [major|minor|patch]
git push
make build-and-commit
git push
make create-release
make publish

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.3.2.tar.gz (20.3 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.3.2-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for netbek_periodic_table-0.3.2.tar.gz
Algorithm Hash digest
SHA256 fde6893d7ee1ee66c3eae6b3e41473b9e9d41cec350245a61fb4c0985939b7b1
MD5 59d780ab00f194235384d721a3478284
BLAKE2b-256 99f4111803281f94b6febaa43d02c5ffb56aae105f23ed38bcb4b1828cfacb47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for netbek_periodic_table-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b4b58105f902b1ee850c5a5cf2dd66aa5504dc0e4487dd9c5feab4807fba0579
MD5 63ac06d4e108c7ec575230e0c2a0a8ed
BLAKE2b-256 3706e6c9a63cc36adc343731fe8fe59f5263d725703a69b11f5b4549b0f2b3a1

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