Skip to content

Commit

Permalink
Merge pull request #1 from tari-project/transfer
Browse files Browse the repository at this point in the history
init: move from tari-labs
  • Loading branch information
shanimal08 authored Jan 31, 2025
2 parents 2495ffd + 6f4af6e commit e85b41e
Show file tree
Hide file tree
Showing 63 changed files with 9,019 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# Publishing all NPM packages to the npm registry when the version number changes
# See https://github.com/marketplace/actions/npm-publish for more information
name: Publish package to npmjs
on:
push:
branches: main

jobs:
# Publish the lib to the NPM registry
publish-typescript-bindings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_PUBLISH_TOKEN }}
access: 'public'
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
/dist/
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"jsxBracketSameLine": false,
"quoteProps": "consistent",
"semi": true,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "all",
"useTabs": true,
"printWidth": 180
}
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
# tari-tower

Source for the tower animation used in [_Tari Universe_](https://github.com/tari-project/universe).

### Installation

```bash
npm i @tari-project/tari-tower
```

## Usage

Initialise

```tsx
import { loadTowerAnimation } from '@tari-project/tari-tower';

loadTowerAnimation();
```

Available methods:

| name | args | description |
| ------------------------ | ------------------------------------------------------------------------------------------------ | -------------------------------------------------- |
| `loadTowerAnimation` | **canvasId**: `string` <br/> **offset?**: `number` | initialise all the animation logic + canvas |
| `removeTowerAnimation` | `none` | stop the animation and remove canvas |
| `setAnimationState` | **id**: `'start'\|'stop'\|'fail'\|'sucess'\|'sucess2'\|'sucess3'` <br/> **isReplay?:** `boolean` | set the animation state |
| `setAnimationProperties` | properties:`{property:string; value:unknown}[]` | set properties (e.g colours in dark vs light mode) |

Available values:

| name | description |
| ---------------------- | --------------------------------------------------------------------------- |
| `animationStatus` | the state of the animation |
| `animationStatusIndex` | the index of the animation state (useful as a trigger in dependencya array) |

## Contributing

### Development

note: _must be built first to be able to reference the lib locally_

```bash
npm ci
npm run build
npm run dev
```

- make changes in the `lib` directory
- export anything you want available in `/lib/main.ts`
- update readme

### Distribution

- make sure your tari labs registry PAT is set up
- bump version in package.json
- build changes:

```bash
npm run build
```

- publish changes:

```
npm publish
```
33 changes: 33 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
import tsParser from '@typescript-eslint/parser';
export default [
pluginJs.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{
ignores: ['node_modules', '/dist/', './public/assets/**/*.js'],
languageOptions: {
globals: globals.browser,
parser: tsParser,
},
rules: {
'no-unused-vars': 'off', // base rule must be disabled
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'none',
caughtErrors: 'all',
ignoreRestSiblings: false,
reportUsedIgnorePattern: false,
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
},
},
eslintConfigPrettier,
];
25 changes: 25 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/x-icon" href="tari.svg" />
<title>Tari Universe Tower Animation</title>
<link rel="modulepreload" href="./src/index.ts" />
<style>
html,
body {
width: 100%;
height: 100%;
margin: 0;
}
body {
overflow: hidden;
}
</style>
</head>
<body>
<div id="root"></div>
<script type="module" src="./src/index.ts"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions lib/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { loadTowerAnimation, removeTowerAnimation } from './scripts/index.ts';
import { properties } from './scripts/core/properties.ts';
import { result, stateManager, status, statusIndex } from './scripts/logic/stateManager.ts';

function setAnimationState(id: string, isReplay = false) {
stateManager.set(id, isReplay);
}

interface Property {
property: string;
value: unknown;
}
function setAnimationProperties(newProps: Property[]) {
for (const item of newProps) {
properties[item.property] = item.value;
}
}

export {
loadTowerAnimation,
removeTowerAnimation,
setAnimationProperties,
status as animationStatus,
statusIndex as animationStatusIndex,
result as animationResult,
setAnimationState,
};
Loading

0 comments on commit e85b41e

Please sign in to comment.