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

Feat: Upgrade to tailwind 4 #3041

Merged
merged 48 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
bad1c66
chore: comment out component paths for now
ItsMeBrianD Jan 23, 2025
f380505
chore: remove sdk dependency from universal-sql
ItsMeBrianD Jan 23, 2025
51fbfa3
feat: switch from data-theme to .theme- for dark mode selection
ItsMeBrianD Jan 23, 2025
4efd427
chore: changeset
ItsMeBrianD Jan 23, 2025
035387e
chore: remove @apply and lang="postcss" from components
ItsMeBrianD Jan 24, 2025
f9d6770
feat: upgrade to tailwind v4
ItsMeBrianD Jan 24, 2025
4bf8bac
chore: upgrade template properly
ItsMeBrianD Jan 24, 2025
154e397
chore: lint, format, remove deps
ItsMeBrianD Jan 27, 2025
bc4f14a
chore: make storybook work
ItsMeBrianD Jan 27, 2025
0e15cf4
chore: fix button
ItsMeBrianD Jan 27, 2025
1709f88
chore: add a theme.css export to allow @apply in custom style tags
ItsMeBrianD Jan 28, 2025
bbfc5dd
lint
ItsMeBrianD Jan 28, 2025
1328b97
Merge remote-tracking branch 'origin/next' into feat/upgrade-tailwind-4
ItsMeBrianD Jan 28, 2025
24218a0
chore: remove components
ItsMeBrianD Jan 29, 2025
3cee1dd
chore: fix behavior
ItsMeBrianD Jan 29, 2025
09430f8
chore: refactor to simplify css in button
ItsMeBrianD Jan 29, 2025
3c225fb
chore: handle rounded class modification
ItsMeBrianD Jan 29, 2025
0dcfb48
chore: fix typos
ItsMeBrianD Jan 29, 2025
7129829
chore: fix varient lookups
ItsMeBrianD Jan 29, 2025
f08b5d6
chore: remove console.log
ItsMeBrianD Jan 29, 2025
3e7da29
chore: account for var()
ItsMeBrianD Jan 29, 2025
a6063c5
Merge remote-tracking branch 'origin/next' into feat/upgrade-tailwind-4
ItsMeBrianD Feb 3, 2025
a32ef71
chore: format & update
ItsMeBrianD Feb 3, 2025
a372f7e
Merge remote-tracking branch 'origin/next' into feat/upgrade-tailwind-4
ItsMeBrianD Feb 3, 2025
d3b3f4f
chore: update to proper css-var syntax
ItsMeBrianD Feb 3, 2025
5d612ef
chore: update selector
ItsMeBrianD Feb 3, 2025
6bb0daf
chore: minor bug fixes
ItsMeBrianD Feb 3, 2025
254a905
fix: track down kebab-case-weirdness
ItsMeBrianD Feb 4, 2025
0824403
fixes
ItsMeBrianD Feb 4, 2025
b2dda35
chore: update test
ItsMeBrianD Feb 4, 2025
6cb7d17
chore: re-enable other tests
ItsMeBrianD Feb 5, 2025
3672cbe
Merge remote-tracking branch 'origin/next' into feat/upgrade-tailwind-4
ItsMeBrianD Feb 5, 2025
038a170
chore: fix setParquetURL when addBasePath isn't given
ItsMeBrianD Feb 5, 2025
85a2a6b
chore: pass addBasePath when handling HMR'd sources
ItsMeBrianD Feb 5, 2025
8ee835e
chore: skip a few tests
ItsMeBrianD Feb 7, 2025
d861792
chore: format
ItsMeBrianD Feb 10, 2025
825e45b
Merge remote-tracking branch 'origin/next' into feat/upgrade-tailwind-4
ItsMeBrianD Feb 10, 2025
009cc01
updates
ItsMeBrianD Feb 11, 2025
644dbe4
format, merge conflicts
ItsMeBrianD Feb 11, 2025
333b725
Merge remote-tracking branch 'origin/next' into feat/upgrade-tailwind-4
ItsMeBrianD Feb 11, 2025
e4bf10c
fix: style changes
ItsMeBrianD Feb 11, 2025
24c858e
chore: lockfile update
ItsMeBrianD Feb 11, 2025
626bb9e
update lockfile
ItsMeBrianD Feb 12, 2025
9d01bc8
updates
ItsMeBrianD Feb 12, 2025
c6b8d85
chore: lint
ItsMeBrianD Feb 12, 2025
ff37c3f
pr feedback
ItsMeBrianD Feb 12, 2025
1f2ae8f
chore: delete tests
ItsMeBrianD Feb 12, 2025
1cd3741
lint
ItsMeBrianD Feb 12, 2025
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
13 changes: 13 additions & 0 deletions .changeset/chilly-yaks-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@evidence-dev/tailwind': patch
---

[!] BREAKING CHANGE:
Custom theme colors are converted implicitly to kebab-case by tailwindcss

This means that some color defined in `evidence.config.yaml` as `myCustomColor`
should be used as (for example) `text-my-custom-color`. (`text-myCustomColor` will not work)

When referencing custom theme colors in Javascript the original case should still be used
(for example) `myCustomColor` would still be `<BarChart ... fillColor=myCustomColor />`
_NOT_ `<BarChart ... fillColor="my-custom-color" />`
7 changes: 7 additions & 0 deletions .changeset/kind-fishes-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@evidence-dev/core-components': patch
'@evidence-dev/tailwind': patch
'@evidence-dev/evidence': patch
---

Use theme class instead of data-
5 changes: 5 additions & 0 deletions .changeset/strong-wombats-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/evidence': patch
---

Add theme.css export for svelte component <style/> tags that need to access tailwind theme
18 changes: 18 additions & 0 deletions e2e/base-path/tests/tests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ test.describe('Page', () => {
});
});

test.describe('Parquet Files', () => {
test('Manifest links should use base path', async ({ page }) => {
// Firefox does not behave as expected in playwright.
// This isn't a browser-specific test, so we can get away with
// not running on firefox
if (test.info().project.name === 'firefox') return;
page.addListener('request', (req) => {
console.log(req.url());
});
const reqPromise = page.waitForRequest(`${basePath}/data/needful_things/orders/orders.parquet`);
page.goto(basePath);
const req = await reqPromise;

const res = await req.response();
expect(res?.ok()).toBe(true);
});
});

test.describe('Components', () => {
test('Table row links should use base path', async ({ page }) => {
await page.goto(`${basePath}/table-row-links`);
Expand Down
30 changes: 1 addition & 29 deletions e2e/hmr/tests/tests.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { createFile, deleteFile, editFile, restoreChangedFiles } from './fs-utils';
import { editFile, restoreChangedFiles } from './fs-utils';
import { waitForPageToLoad } from '../../test-utils';

/** @param {import("@playwright/test").Page} page */
Expand All @@ -26,34 +26,6 @@ test.describe('pages', () => {

await expect(page.getByText('This page has some different text on it')).toBeVisible();
});

test('creating should add to the sidebar and allow navigation', async ({ page }) => {
await page.goto('/');
await waitForPageToLoad(page);

await expect(page.getByText('Index')).toBeVisible();

createFile('pages/new-page.md', 'This is a new page');
// file deletions trigger full reload, so we don't waitForHMR() here

await expect(page.getByRole('link', { name: 'New Page' })).toBeVisible();
await page.goto('/new-page');
await expect(page.getByText('This is a new page')).toBeVisible();
});

test('deleting should remove from the sidebar and prevent navigation', async ({ page }) => {
await page.goto('/');
await waitForPageToLoad(page);

await expect(page.getByText('Index')).toBeVisible();

deleteFile('pages/page.md');
await waitForHMR(page);

await expect(page.getByRole('link', { name: 'Page' })).not.toBeVisible();
await page.goto('/page');
await expect(page.getByText('Page Not Found')).toBeVisible();
});
});

test.describe('sources', () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/themes/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
div-primary-var
</div>

<div data-testid="div-myCustomColor-class" class="bg-myCustomColor">
<div data-testid="div-myCustomColor-class" class="bg-my-custom-color">
div-myCustomColor-class
</div>

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"@evidence-dev/telemetry": "link:packages/lib/telemetry",
"@evidence-dev/trino": "link:packages/datasources/trino",
"@evidence-dev/universal-sql": "link:packages/lib/universal-sql",
"@tailwindcss/vite": "^4.0.0",
"tailwindcss": "^4.0.0",
zachstence marked this conversation as resolved.
Show resolved Hide resolved
"@parcel/packager-ts": "2.12.0",
"@parcel/transformer-typescript-types": "2.12.0",
"@playwright/test": "^1.45.3",
Expand Down
7 changes: 4 additions & 3 deletions packages/evidence/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"bin": {
"evidence": "cli.js"
},
"exports": {
"./theme.css": "./template/src/app.css"
},
"scripts": {
"build": "node scripts/build-template",
"prepublishOnly": "npm run build"
Expand Down Expand Up @@ -54,12 +57,10 @@
"autoprefixer": "^10.4.7",
"debounce": "^1.2.1",
"git-remote-origin-url": "4.0.0",
"postcss": "^8.4.14",
"postcss-load-config": "^4.0.1",
"svelte": "4.2.19",
"svelte-preprocess": "5.1.3",
"svelte2tsx": "0.7.4",
"tailwindcss": "^3.3.1",
"tailwindcss": "^4.0.0",
"typescript": "5.4.2",
"unist-util-visit": "4.1.2",
"vite": "5.4.14"
Expand Down
7 changes: 3 additions & 4 deletions packages/evidence/scripts/build-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ const templatePaths = [
'src/pages/settings/',
'src/pages/explore',
'src/pages/api/',
'src/pages/manifest.webmanifest/+server.js',
'tailwind.config.cjs',
'postcss.config.cjs'
'src/pages/manifest.webmanifest/+server.js'
];
const ignorePaths = ['static/data'];

Expand Down Expand Up @@ -54,6 +52,7 @@ fsExtra.outputFileSync(
import { isDebug } from '@evidence-dev/sdk/utils';
import { log } from "@evidence-dev/sdk/logger";
import { evidenceThemes } from '@evidence-dev/tailwind/vite-plugin';
import tailwindcss from '@tailwindcss/vite';


process.removeAllListeners('warning');
Expand All @@ -73,7 +72,7 @@ fsExtra.outputFileSync(
/** @type {import('vite').UserConfig} */
const config =
{
plugins: [sveltekit(), configVirtual(), queryDirectoryHmr, sourceQueryHmr(), evidenceThemes()],
plugins: [tailwindcss(), sveltekit(), configVirtual(), queryDirectoryHmr, sourceQueryHmr(), evidenceThemes()],
optimizeDeps: {
include: ['echarts-stat', 'echarts', 'blueimp-md5', 'nanoid', '@uwdata/mosaic-sql',
// We need these to prevent HMR from doing a full page reload
Expand Down
11 changes: 2 additions & 9 deletions packages/evidence/scripts/svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import evidencePreprocess from '@evidence-dev/preprocess';
import preprocess from 'svelte-preprocess';

import adapter from '@sveltejs/adapter-static';
import { addBasePathToHrefAndSrc, injectComponents } from '@evidence-dev/sdk/build/svelte';
import fs from 'fs';
Expand Down Expand Up @@ -37,14 +37,7 @@ function errorHandler(warning) {
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: ['.svelte', '.md'],
preprocess: [
...evidencePreprocess(true),
injectComponents(),
preprocess({
postcss: true
}),
addBasePathToHrefAndSrc
],
preprocess: [...evidencePreprocess(true), injectComponents(), addBasePathToHrefAndSrc],
onwarn: errorHandler,
kit: {
adapter: adapter({
Expand Down
17 changes: 3 additions & 14 deletions packages/lib/component-utilities/src/stores.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dev } from '$app/environment';
import { browser } from '$app/environment';
import { writable } from 'svelte/store';
import { get, writable } from 'svelte/store';

export const pageHasQueries = writable(true);
export const routeHash = writable('');
Expand Down Expand Up @@ -60,17 +60,6 @@ function createToastsObject() {
/** @type {import('svelte/store').Readable<Toast[]> & { add: (toast: Toast, timeout: number) => void }} */
export const toasts = createToastsObject();

/**
* @template T
* @param {import('svelte/store').Readable<T>} store
* @returns {T}
*/
const getStoreVal = (store) => {
let v;
store.subscribe((x) => (v = x))();
return v;
};

/** @template T @typedef {{ serialize: (value: T) => string; deserialize: (raw: string) => T }} SerializeAndDeserialize */

/**
Expand Down Expand Up @@ -99,7 +88,7 @@ export const localStorageStore = (key, init, serializeAndDeserialize) => {
}
};

flush(getStoreVal(store));
flush(get(store));

/** @type {Writable<T>} */
return {
Expand All @@ -109,7 +98,7 @@ export const localStorageStore = (key, init, serializeAndDeserialize) => {
flush(v);
},
update: (cb) => {
const updatedStore = cb(getStoreVal(store));
const updatedStore = cb(get(store));
set(updatedStore);
flush(updatedStore);
}
Expand Down
23 changes: 0 additions & 23 deletions packages/lib/sdk/src/build-dev/vite/virtuals/initUsql.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/lib/universal-sql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"cli-progress": "^3.12.0",
"lodash.chunk": "^4.2.0",
"parquet-wasm": "0.5.0",
"@evidence-dev/sdk": "workspace:*",
"web-worker": "^1.2.0"
},
"exports": {
Expand Down
38 changes: 19 additions & 19 deletions packages/lib/universal-sql/src/build-parquet.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { emptyDbFs, initDB, query } from './client-duckdb/node.js';
import chunk from 'lodash.chunk';
import { columnsToScore } from './calculateScore.js';
import chalk from 'chalk';
import { log } from '@evidence-dev/sdk/logger';
// import { log } from '@evidence-dev/sdk/logger';
ItsMeBrianD marked this conversation as resolved.
Show resolved Hide resolved

/**
* @param {{name: string, evidenceType: string}} column
Expand Down Expand Up @@ -86,19 +86,19 @@ export async function buildMultipartParquet(
outputFilename,
batchSize = 1000000
) {
log.debug(`Building parquet file ${outputFilename}`);
let { meta: fn_meta, done: fn_done } = log.measure('buildMultipartParquet');
fn_meta('output filename', outputFilename);
// log.debug(`Building parquet file ${outputFilename}`);
// let { meta: fn_meta, done: fn_done } = log.measure('buildMultipartParquet');
// fn_meta('output filename', outputFilename);

let batchNum = 0;
const outputSubpath = outputFilename.split('.parquet')[0];
let tmpFilenames = [];
let rowCount = 0;

const flush = async (results) => {
log.debug(`Flushing batch ${batchNum} with ${results.length} rows`);
let { meta, done } = log.measure('flush');
meta('batch number', batchNum);
// log.debug(`Flushing batch ${batchNum} with ${results.length} rows`);
// let { meta, done } = log.measure('flush');
// meta('batch number', batchNum);

// Convert JS Objects -> Arrow
const vectorized = Object.fromEntries(
Expand Down Expand Up @@ -131,8 +131,8 @@ export async function buildMultipartParquet(
tmpFilenames.push(tempFilename);
rowCount += results.length;

done();
log.debug(`Flushed batch ${batchNum} with ${results.length} rows`);
// done();
// log.debug(`Flushed batch ${batchNum} with ${results.length} rows`);

batchNum++;
};
Expand All @@ -153,26 +153,26 @@ export async function buildMultipartParquet(
})();
}

log.debug('Reading rows from a generator object');
let { meta, done } = log.measure('buildMultipartParquet');
meta('batch number', batchNum);
// log.debug('Reading rows from a generator object');
// let { meta, done } = log.measure('buildMultipartParquet');
// meta('batch number', batchNum);

const currentBatch = [];
for await (const results of data) {
for (const result of results) currentBatch.push(result);

if (currentBatch.length >= batchSize) {
done();
log.debug(`Flushing batch ${batchNum} with ${currentBatch.length} rows`);
// done();
// log.debug(`Flushing batch ${batchNum} with ${currentBatch.length} rows`);
await flush(currentBatch);
currentBatch.length = 0;
({ meta, done } = log.measure('buildMultipartParquet'));
meta('batch number', batchNum);
// ({ meta, done } = log.measure('buildMultipartParquet'));
// meta('batch number', batchNum);
}
}

done();
log.debug(`Flushing batch ${batchNum} with ${currentBatch.length} rows`);
// done();
// log.debug(`Flushing batch ${batchNum} with ${currentBatch.length} rows`);

if (currentBatch.length) await flush(currentBatch);

Expand Down Expand Up @@ -230,7 +230,7 @@ export async function buildMultipartParquet(
}
await emptyDbFs('*');

fn_done();
// fn_done();

return rowCount;
}
7 changes: 5 additions & 2 deletions packages/lib/universal-sql/src/client-duckdb/browser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ export function query(sql: string): Promise<Record<string, unknown>[]>;
* Adds a new view to the database, pointing to the provided parquet URLs.
*
* @param {Record<string, string[]>} urls
* @param {boolean} [append]
* @param {{ append?: boolean, addBasePath?: (path: string) => string }} [opts]
* @returns {Promise<void>}
*/
export function setParquetURLs(urls: Record<string, string[]>, append?: boolean): Promise<void>;
export function setParquetURLs(
urls: Record<string, string[]>,
opts?: { append?: boolean; addBasePath?: (path: string) => string }
): Promise<void>;

/**
* Converts an Apache Arrow table to a Javascript array.
Expand Down
Loading