Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tram-One, now with Types! Typescript! v11.0.0 #175

Merged
merged 28 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
dc2bf8c
Initial Pass at migrating to Typescript
JRJurman Oct 21, 2021
a43298e
re-add lint (placeholder)
JRJurman Oct 21, 2021
e56dc64
migrate test app to ts as well
JRJurman Oct 21, 2021
64dab27
type definitions!
JRJurman Oct 22, 2021
1b76e38
npm ci in pipeline
JRJurman Oct 22, 2021
1ca3030
11.0.0
JRJurman Oct 22, 2021
349d159
remove manual type checks
JRJurman Oct 22, 2021
839e459
add eslint typescript config
JRJurman Oct 22, 2021
029217e
fix lint, add comments to config, update test files to ts
JRJurman Oct 23, 2021
fdcadee
cleanup jsdocs, more types, add unit test for root effect
JRJurman Oct 24, 2021
30f8370
use prettier
JRJurman Oct 24, 2021
f18e844
fix docstring, update dependency name in config
JRJurman Oct 24, 2021
7e8d7fd
clean up layout for tasks test component
JRJurman Oct 24, 2021
c6842cf
Update README
JRJurman Oct 24, 2021
c8a677e
more strict typing
JRJurman Oct 25, 2021
771d55e
formatting for test app
JRJurman Oct 25, 2021
ca74d2a
Fix app by being dependent on loading
JRJurman Oct 29, 2021
31024f5
fix performance test ts
JRJurman Oct 29, 2021
8195f6b
use functions for node filter
JRJurman Oct 30, 2021
da0e1fb
typescript build config
JRJurman Nov 3, 2021
74e2788
use parcel 2.0
JRJurman Nov 3, 2021
2edd8c2
strictNullChecks, remove domino
JRJurman Nov 6, 2021
d7727f9
rearrange and expose types in main export
JRJurman Nov 8, 2021
1df7179
strict ruleset, update test files to verify type
JRJurman Nov 8, 2021
0968852
change to type module
JRJurman Nov 8, 2021
2914e36
update runkit example
JRJurman Nov 8, 2021
eb88229
update eslint, remove logs, expose TramOneElement
JRJurman Nov 10, 2021
adef448
fixes for code coverage
JRJurman Nov 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
fingerprints:
- "64:3e:d4:d8:4b:95:68:79:d3:3b:ab:b1:5c:fa:2d:3d"

- run: npm install
- run: npm ci
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this project originally predated npm ci, but now that it exists, we should be using that, and not regenerating the lock file on every PR.


- save_cache:
paths:
Expand Down
4 changes: 3 additions & 1 deletion configs/rollup.config.cjs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const filesize = require('rollup-plugin-filesize')
const commonjs = require('rollup-plugin-commonjs')
const pkg = require('../package.json')
const typescript = require('@rollup/plugin-typescript')

const external = Object.keys(pkg.dependencies)
.concat([
Expand All @@ -11,12 +12,13 @@ const external = Object.keys(pkg.dependencies)
])

const plugins = [
typescript(),
commonjs(),
filesize()
]

export default {
input: 'src/tram-one',
input: 'src/tram-one.ts',
external,
plugins,
output: {
Expand Down
4 changes: 3 additions & 1 deletion configs/rollup.config.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ const filesize = require('rollup-plugin-filesize')
const globals = require('rollup-plugin-node-globals')
const resolve = require('rollup-plugin-node-resolve')
const { terser } = require('rollup-plugin-terser')
const typescript = require('@rollup/plugin-typescript')
// const sizes = require('rollup-plugin-sizes')

const pkg = require('../package.json')

const plugins = [
typescript(),
resolve({
preferBuiltins: true,
browser: true
Expand All @@ -25,7 +27,7 @@ const plugins = [
// domino is a package used by belit to support server side rendering,
// it does not need to be included in browser builds, which will have document
export default {
input: 'src/tram-one',
input: 'src/tram-one.ts',
external: ['domino'],
output: {
name: 'tram-one',
Expand Down
4 changes: 2 additions & 2 deletions docs/badges/cjs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions docs/badges/umd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { registerHtml, useUrlParams } = require('../../src/tram-one')
import { registerHtml, useUrlParams } from '../../src/tram-one'

const html = registerHtml()

/**
* component to test url parameters
*/
module.exports = () => {
export default () => {
const { account, loggedIn = 'No' } = useUrlParams('/:account')
return html`
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { registerHtml, useStore } = require('../../src/tram-one')
import { registerHtml, useStore } from '../../src/tram-one'

const html = registerHtml()

/**
* component to test local state management
*/
module.exports = () => {
export default () => {
const totalClicks = useStore({ clicks: 0 })
const incrementClicks = () => totalClicks.clicks++
return html`
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/test-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
</head>
<body>
<div id="parcel-page"></div>
<script src="./index.js"></script>
<script type="module" src="./index.ts"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
const { registerHtml, start } = require('../../src/tram-one')
import { registerHtml, start } from '../../src/tram-one'
import title from './title'
import logo from './logo'
import clicktracker from './click-tracker'
import startupwait from './startup-wait'
import tab from './tab'
import account from './account'
import tasks from './tasks'
import mirrorinput from './mirror-input'

const html = registerHtml({
'title': require('./title'),
'logo': require('./logo'),
'click-tracker': require('./click-tracker'),
'startup-wait': require('./startup-wait'),
'tab': require('./tab'),
'account': require('./account'),
'tasks': require('./tasks'),
'mirror-input': require('./mirror-input')
'title': title,
'logo': logo,
'click-tracker': clicktracker,
'startup-wait': startupwait,
'tab': tab,
'account': account,
'tasks': tasks,
'mirror-input': mirrorinput
})

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { registerSvg } = require('../../src/tram-one')
import { registerSvg } from '../../src/tram-one'

const svg = registerSvg()

/**
* component to test svg functionality
*/
module.exports = () => {
export default () => {
return svg`
<svg class="logo" viewBox="0 0 20 10" xmlns="http://www.w3.org/2000/svg" style="max-width: 10em">
<circle cx="5" cy="5" r="4" role="logo">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const { registerHtml, useGlobalStore } = require('../../src/tram-one')
import { registerHtml, useGlobalStore } from '../../src/tram-one'
import submirrorinput from './sub-mirror-input'

const html = registerHtml({
'sub-mirror-input': require('./sub-mirror-input')
'sub-mirror-input': submirrorinput
})

/**
* component to test url parameters
*/
module.exports = () => {
export default () => {
const mirrorable = useGlobalStore('mirrorable-input', { value: '' })

const onEvent = event => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { registerHtml, useStore, useEffect } = require('../../src/tram-one')
import { registerHtml, useStore, useEffect } from '../../src/tram-one'

const html = registerHtml()

/**
* component to test effects on mount
*/
module.exports = () => {
export default () => {
const initialWait = useStore({ isDone: false })

// after the element first renders, run effect to set isDone to true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const { registerHtml, useGlobalStore } = require('../../src/tram-one')
import { registerHtml, useGlobalStore } from '../../src/tram-one'

const html = registerHtml({
'sub-mirrorable-input': require('./sub-mirror-input')
})

type InputObject = { value: string }

/**
* component to test url parameters
*/
module.exports = () => {
const mirrorable = useGlobalStore('mirrorable-input')
export default () => {
const mirrorable = useGlobalStore('mirrorable-input') as InputObject

const onEvent = event => {
mirrorable.value = event.target.value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
const { registerHtml, useEffect, useGlobalStore, useStore } = require('../../src/tram-one')
import { registerHtml, useEffect, useGlobalStore, useStore } from '../../src/tram-one'

const html = registerHtml()

type TabState = {
tabWasUpdated: boolean,
tabWasDismissed: boolean,
shouldDisplayTab: boolean,
isTabLocked: boolean,
loading: boolean
}

/**
* Component for testing effects and global state
* It can be removed by clicking "Dismiss".
* Its effects can be refreshed (cleaned up) by clicking "Lock Tab"
*/
module.exports = () => {
// global state that controls if the tab is shown and what it shows
const tabState = useGlobalStore('tab-state')
const tabState = useGlobalStore('tab-state') as TabState

// local tab state for testing local effect changes
const previousLockState = useStore({ locked: false })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { registerHtml } = require('../../src/tram-one')
import { registerHtml } from '../../src/tram-one'

const html = registerHtml()

/**
* component to test basic rendering
*/
module.exports = (props, children) => {
export default (props, children) => {
return html`
<h2>${children}</h2>
`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { registerHtml, useGlobalStore, useEffect } = require('../../src/tram-one')
import { registerHtml, useGlobalStore, useEffect } from '../../src/tram-one'

const html = registerHtml({
'sub-tab': require('./sub-tab')
Expand All @@ -15,7 +15,7 @@ const defaultTabState = {
/**
* component to test global state and control sub-tab (which has cleanup effects)
*/
module.exports = () => {
export default () => {
const tabState = useGlobalStore('tab-state', defaultTabState)

// immediately update the state (verifies effects on mount)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { registerHtml, useStore } = require('../../src/tram-one')
import { registerHtml, useStore } from '../../src/tram-one'

const html = registerHtml()

/**
* component to test url parameters
*/
module.exports = () => {
export default () => {
const tasks = useStore([])
const newTask = useStore({ label: `Task Number ${tasks.length}`, type: 'Projects' })

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const { registerHtml } = require('../../src/tram-one')
import { registerHtml } from '../../src/tram-one'
import subtitle from './sub-title'

const html = registerHtml({
// sub-title to test multiple instances of the same tag
'sub-title': require('./sub-title')
'sub-title': subtitle
})

/**
* component to test basic rendering
*/
module.exports = (props, children) => {
export default (props, children) => {
const { subtitle = '' } = props
return html`
<header>
Expand Down
6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
testEnvironment: 'jsdom'
testEnvironment: 'jsdom',
transform: {
'^.+\\.ts?$': 'ts-jest'
},
moduleFileExtensions: ['ts', 'js']
}
Loading