Skip to content

Commit

Permalink
Merge pull request #5 from x0k/packages
Browse files Browse the repository at this point in the history
Packages
  • Loading branch information
x0k authored Oct 26, 2024
2 parents 8523354 + a01205e commit b3574b3
Show file tree
Hide file tree
Showing 132 changed files with 9,035 additions and 5,394 deletions.
49 changes: 0 additions & 49 deletions .github/workflows/deploy-pages.yml

This file was deleted.

74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Release
on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
id-token: write
contents: write
pull-requests: write
pages: write

jobs:
version:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Checkout code repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install dependencies
run: pnpm install

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Build
run: pnpm run ci:build

- name: create and publish versions
uses: changesets/action@v1
with:
version: pnpm ci:version
publish: pnpm exec changeset publish
commit: "[ci] release"
title: "[ci] release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Merge apps build outputs
run: mv apps/docs/dist apps/web/dist/docs

- name: Upload Pages Artifact
uses: actions/upload-pages-artifact@v3
with:
path: "apps/web/dist/"

deploy:
needs: version
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
.direnv/

node_modules

.turbo

*.tsbuildinfo
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
# JSON to Table
# JSON Table

[App for converting JSON data to table (HTML, XLSX, ASCII)](https://x0k.github.io/json-to-table/)
Set of tools for converting JSON data into tables (HTML, XLSX, ASCII).

## Example
- [Web App](https://x0k.github.io/json-table/)
- [Documentation](https://x0k.github.io/json-table/docs/)

## Install

```shell
npm install @json-table/core
```

## Usage

```typescript
import { makeTableInPlaceBaker, makeTableFactory } from "@json-table/core/json-to-table";
import { blockToASCII } from "@json-table/core/block-to-ascii";

const cornerCellValue = "";
const factory = makeTableFactory({ cornerCellValue });
const bake = makeTableInPlaceBaker({ cornerCellValue, head: true, indexes: true });
const asciiTable = blockToASCII(bake(factory(data)));
```

Input data:

Expand Down Expand Up @@ -47,6 +66,10 @@ Output:
+-----+---------------+--------+------+-----------+---+-------+-----+--------+
```

## License

MIT

## See also

- Use this app to render JSON responses as tables in your browser by [WebMaid](https://github.com/x0k/web-maid/tree/main/examples/json-to-table)
Expand Down
21 changes: 21 additions & 0 deletions apps/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# build output
dist/
# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*


# environment variables
.env
.env.production

# macOS-specific files
.DS_Store
1 change: 1 addition & 0 deletions apps/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Docs
42 changes: 42 additions & 0 deletions apps/docs/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// @ts-check
import { fileURLToPath } from 'node:url'
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";
import svelte from "@astrojs/svelte";

// https://astro.build/config
export default defineConfig({
site: "https://x0k.github.io",
base: "/json-table/docs/",
trailingSlash: "always",
i18n: {
defaultLocale: "en",
locales: ["en"],
},
integrations: [
svelte(),
starlight({
title: "JSON Table",
social: {
github: "https://github.com/x0k/json-table",
},
sidebar: [
// {
// label: "Guides",
// autogenerate: { directory: "guides" },
// },
],
components: {
Head: "./src/components/custom-head.astro",
Header: "./src/components/header-with-links.astro",
},
}),
],
vite: {
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
},
});
22 changes: 22 additions & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "docs",
"private": true,
"type": "module",
"version": "0.0.0",
"scripts": {
"dev": "astro dev",
"build": " astro build",
"preview": "astro preview",
"check": "astro check"
},
"devDependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/starlight": "^0.28.3",
"@astrojs/svelte": "^5.7.2",
"astro": "^4.16.6",
"astro-vtbot": "^1.10.3",
"sharp": "^0.33.5",
"starlight-package-managers": "^0.7.0",
"svelte": "^5.1.0"
}
}
1 change: 1 addition & 0 deletions apps/docs/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions apps/docs/src/astor.svelte.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
type DarkOrLight = "light" | "dark";
type Theme = "auto" | DarkOrLight;

const STORAGE_KEY = "starlight-theme";

const parseTheme = (theme: unknown): Theme =>
theme === "auto" || theme === "dark" || theme === "light" ? theme : "auto";

const loadTheme = (): Theme =>
parseTheme(
typeof localStorage !== "undefined" && localStorage.getItem(STORAGE_KEY)
);

const getPreferredColorScheme = (): DarkOrLight =>
matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";

export function theme() {
let theme = $state(loadTheme());

$effect(() => {
const starlightThemeSelect = document
.getElementsByTagName("starlight-theme-select")
.item(0);
if (starlightThemeSelect === null) {
return;
}
const themeSelect = starlightThemeSelect
.getElementsByTagName("select")
.item(0);
if (themeSelect === null) {
return;
}
const updateTheme = (e: Event) => {
if (!(e.currentTarget instanceof HTMLSelectElement)) {
return;
}
theme = parseTheme(e.currentTarget.value);
};
themeSelect.addEventListener("change", updateTheme);
return () => themeSelect.removeEventListener("change", updateTheme);
});

const darkOrLight = $derived(
theme === "auto" ? getPreferredColorScheme() : theme
);

return {
get theme() {
return theme;
},
get darkOrLight() {
return darkOrLight;
},
};
}
11 changes: 11 additions & 0 deletions apps/docs/src/components/custom-head.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
import type { Props } from "@astrojs/starlight/props";
import StarlightHead from "@astrojs/starlight/components/Head.astro";
import VtbotStarlight from "astro-vtbot/components/starlight/Base.astro";
import PageOffset from "astro-vtbot/components/PageOffset.astro";
---

<VtbotStarlight {...Astro.props} transition:animate="fade">
<StarlightHead {...Astro.props}><slot /></StarlightHead>
</VtbotStarlight>
<PageOffset name="main" />
Loading

0 comments on commit b3574b3

Please sign in to comment.