Re: Factor

Factor: the language, the theory, and the practice.

Periodic Table

Friday, September 1, 2023

#ui

Despite the difficulty that I had with freshman chemistry, I’ve always enjoyed learning about the periodic table, writing blog posts about making words with element symbols, and I do think it would be awesome to have a giant wall-mounted periodic table like Bill Gates has in his office.

The other day I wanted to demonstrate the UI framework by making another simple UI gadget. It occurred to me that we could make a simple periodic table as an example.

The code is about 140 lines to define all the elements and their groups, 10 lines to organize them into a table, and about 40 lines to build the element boxes, put them into a gadget, and add a legend at the bottom. Each element is a <roll-button> that opens the appropriate Wikipedia page for each chemical element.

I was reminded of this recently by a funny comment on the Factor Discord:

Factor crushing the competition thanks to periodic-table vocab

https://codegolf.stackexchange.com/questions/264714/is-it-an-element/264723#264723

You can view the source code for the periodic table vocabulary or try it yourself:

IN: scratchpad "periodic-table" run