Skip to content

Commit

Permalink
move types into src/lib/index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Jan 3, 2023
1 parent 39da8c1 commit b706882
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 68 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ jobs:
run: |
npm install
npm run package
npm login
npm publish ./package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion src/lib/ElementHeading.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { ChemicalElement } from './types'
import type { ChemicalElement } from './'
export let element: ChemicalElement
export let style = ``
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ElementTile.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { ChemicalElement } from '.'
import { pretty_num } from './labels'
import type { ChemicalElement } from './types'
export let element: ChemicalElement
export let bg_color: string | null = null
Expand Down
2 changes: 1 addition & 1 deletion src/lib/PeriodicTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import { extent } from 'd3-array'
import type { ScaleLinear } from 'd3-scale'
import { scaleLinear, scaleLog } from 'd3-scale'
import type { ChemicalElement } from '.'
import element_data from './element-data'
import ElementPhoto from './ElementPhoto.svelte'
import ElementTile from './ElementTile.svelte'
import { active_category, active_element, last_element } from './stores'
import type { ChemicalElement } from './types'
export let show_names = true
export let show_numbers = true
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ScatterPlot.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import { bisector, extent } from 'd3-array'
import type { ScaleLinear } from 'd3-scale'
import { scaleLinear } from 'd3-scale'
import type { ChemicalElement, PlotPoint } from '.'
import element_data from './element-data'
import { pretty_num } from './labels'
import Line from './Line.svelte'
import ScatterPoint from './ScatterPoint.svelte'
import { active_element } from './stores'
import type { ChemicalElement, PlotPoint } from './types'
export let style = ``
export let x_lim: [number | null, number | null] = [null, null]
Expand Down
60 changes: 58 additions & 2 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,67 @@
export { default as BohrAtom } from './BohrAtom.svelte'
export { default as ColorCustomizer } from './ColorCustomizer.svelte'
export { default as element_data } from './element-data.ts'
export { default as element_data } from './element-data'
export { default as ElementPhoto } from './ElementPhoto.svelte'
export { default as ElementStats } from './ElementStats.svelte'
export { default as ElementTile } from './ElementTile.svelte'
export { default, default as PeriodicTable } from './PeriodicTable.svelte'
export { default as ScatterPlot } from './ScatterPlot.svelte'
export { default as TableInset } from './TableInset.svelte'
export { default as Toggle } from './Toggle.svelte'
export * as types from './types.ts'

export type Category =
| `diatomic nonmetal`
| `noble gas`
| `alkali metal`
| `alkaline earth metal`
| `metalloid`
| `polyatomic nonmetal`
| `transition metal`
| `post-transition metal`
| `lanthanide`
| `actinide`

export type ChemicalElement = {
appearance: string
atomic_mass: number
atomic_radius: number
boiling_point: number | null
category: Category
column: number // aka group, in range 1 - 18
covalent_radius: number
density: number
discoverer: string
electron_affinity: number
electron_configuration_semantic: string
electron_configuration: string
electronegativity_pauling: number | null
electronegativity: number | null
first_ionization: number
ionization_energies: number[]
jmol_color: string
melting_point: number | null
metal: boolean | null
metalloid: boolean | null
molar_heat: number | null
n_electrons: number
n_neutrons: number
n_protons: number
n_shells: number
n_valence: number
name: string
natural: boolean | null
nonmetal: boolean | null
number_of_isotopes: number
number: number
phase: 'Gas' | 'Liquid' | 'Solid'
radioactive: boolean | null
row: number // != period for lanthanides and actinides
shells: number[]
specific_heat: number
spectral_img: string
summary: string
symbol: string
year: number | string
}

export type PlotPoint = [number, number, ChemicalElement]
2 changes: 1 addition & 1 deletion src/lib/labels.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ChemicalElement } from './types'
import type { ChemicalElement } from '.'

// TODO add labels and units for all elemental properties
export const property_labels: Partial<
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stores.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { writable } from 'svelte/store'
import type { Category, ChemicalElement } from './types'
import type { Category, ChemicalElement } from '.'

export const active_category = writable<Category | null>(null)

Expand Down
56 changes: 0 additions & 56 deletions src/lib/types.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/routes/[slug]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import type { ChemicalElement } from '$lib'
import { element_data } from '$lib'
import BohrAtom from '$lib/BohrAtom.svelte'
import ElementHeading from '$lib/ElementHeading.svelte'
Expand All @@ -8,7 +9,6 @@
import PeriodicTable from '$lib/PeriodicTable.svelte'
import ScatterPlot from '$lib/ScatterPlot.svelte'
import { active_element, heatmap_key } from '$lib/stores'
import type { ChemicalElement } from '$lib/types'
import PrevNextElement from '$site/PrevNextElement.svelte'
import PropertySelect from '$site/PropertySelect.svelte'
import { extent } from 'd3-array'
Expand Down
2 changes: 1 addition & 1 deletion src/site/PrevNextElement.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import type { ChemicalElement } from '$lib'
import Icon from '@iconify/svelte'
import ElementPhoto from '../lib/ElementPhoto.svelte'
import ElementTile from '../lib/ElementTile.svelte'
import type { ChemicalElement } from '../lib/types'
export let prev: ChemicalElement
export let next: ChemicalElement
Expand Down
2 changes: 1 addition & 1 deletion src/site/PropertySelect.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import type { ChemicalElement } from '$lib'
import Select from 'svelte-multiselect'
import { heatmap_labels } from '../lib/labels'
import { heatmap_key } from '../lib/stores'
import type { ChemicalElement } from '../lib/types'
export let value: keyof ChemicalElement | null = null
export let selected: string[] = []
Expand Down

0 comments on commit b706882

Please sign in to comment.