diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb34ee4055280..a40c26f218a1b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,14 +52,6 @@ repos: - id: trailing-whitespace exclude: ^.*\.(snap) args: ["--markdown-linebreak-ext=md"] - - repo: local - hooks: - - id: eslint - name: eslint - entry: bash -c 'cd superset-frontend && npm run eslint -- $(echo "$@" | sed "s|superset-frontend/||g")' - language: system - pass_filenames: true - files: \.(js|jsx|ts|tsx)$ - repo: https://github.com/pre-commit/mirrors-prettier rev: v4.0.0-alpha.8 # Use the sha or tag you want to point at hooks: @@ -68,6 +60,14 @@ repos: - prettier@3.3.3 args: ["--ignore-path=./superset-frontend/.prettierignore"] files: "superset-frontend" + - repo: local + hooks: + - id: eslint + name: eslint + entry: bash -c 'cd superset-frontend && npm run eslint -- $(echo "$@" | sed "s|superset-frontend/||g")' + language: system + pass_filenames: true + files: \.(js|jsx|ts|tsx)$ # blacklist unsafe functions like make_url (see #19526) - repo: https://github.com/skorokithakis/blacklist-pre-commit-hook rev: e2f070289d8eddcaec0b580d3bde29437e7c8221 diff --git a/superset-frontend/.eslintrc.js b/superset-frontend/.eslintrc.js index 5f5acaa6d64fb..ddf7cb2eff0cb 100644 --- a/superset-frontend/.eslintrc.js +++ b/superset-frontend/.eslintrc.js @@ -280,7 +280,7 @@ module.exports = { 'fixtures.*', 'cypress-base/cypress/**/*', 'Stories.tsx', - 'packages/superset-ui-core/src/style/index.tsx', + 'packages/superset-ui-core/src/theme/index.tsx', ], rules: { 'theme-colors/no-literal-colors': 0, diff --git a/superset-frontend/.prettierignore b/superset-frontend/.prettierignore index 790231eb298cb..4fe6cf6c11c82 100644 --- a/superset-frontend/.prettierignore +++ b/superset-frontend/.prettierignore @@ -26,5 +26,7 @@ CHANGELOG/ *-topo.json storybook-static/ *.snap +**/*.less +**/*.less.hbs /.nx/workspace-data diff --git a/superset-frontend/.storybook/preview.jsx b/superset-frontend/.storybook/preview.jsx index ef27f3591e806..fb3d513a27533 100644 --- a/superset-frontend/.storybook/preview.jsx +++ b/superset-frontend/.storybook/preview.jsx @@ -17,8 +17,8 @@ * under the License. */ import { withJsx } from '@mihkeleidast/storybook-addon-source'; -import { supersetTheme, ThemeProvider } from '@superset-ui/core'; -import { AntdThemeProvider } from '../src/components/AntdThemeProvider'; +import { themeObject } from '@superset-ui/core'; +import { theme } from 'src/preamble'; import { combineReducers, createStore, applyMiddleware, compose } from 'redux'; import thunk from 'redux-thunk'; import { Provider } from 'react-redux'; @@ -34,14 +34,14 @@ const store = createStore( compose(applyMiddleware(thunk)), ); -const themeDecorator = Story => ( - - +const themeDecorator = Story => { + return ( + - - -); + + ); +}; const providerDecorator = Story => ( diff --git a/superset-frontend/.storybook/storybook.css b/superset-frontend/.storybook/storybook.css index b4e2fce55b7df..25fa51c5a8bd9 100644 --- a/superset-frontend/.storybook/storybook.css +++ b/superset-frontend/.storybook/storybook.css @@ -1,3 +1,2 @@ body { - background: transparent; } diff --git a/superset-frontend/cypress-base/cypress/e2e/dashboard_list/list.test.ts b/superset-frontend/cypress-base/cypress/e2e/dashboard_list/list.test.ts index c887ae0e6c2c3..fecd663987194 100644 --- a/superset-frontend/cypress-base/cypress/e2e/dashboard_list/list.test.ts +++ b/superset-frontend/cypress-base/cypress/e2e/dashboard_list/list.test.ts @@ -40,25 +40,18 @@ function openMenu() { cy.get('[aria-label="more-vert"]').first().click(); } -function confirmDelete(bulk = false) { - interceptDelete(); - interceptBulkDelete(); - +function confirmDelete() { // Wait for modal dialog to be present and visible cy.get('[role="dialog"][aria-modal="true"]').should('be.visible'); - cy.getBySel('delete-modal-input') - .should('be.visible') - .then($input => { - cy.wrap($input).clear(); - cy.wrap($input).type('DELETE'); - }); - cy.getBySel('modal-confirm-button').should('be.visible').click(); - if (bulk) { - cy.wait('@bulkDelete'); - } else { - cy.wait('@delete'); - } + // Handle the delete input field + cy.getBySel('delete-modal-input').should('be.visible'); + cy.getBySel('delete-modal-input').clear(); + cy.getBySel('delete-modal-input').type('DELETE'); + + // Handle the confirm button + cy.getBySel('modal-confirm-button').should('be.visible'); + cy.getBySel('modal-confirm-button').click(); } describe('Dashboards list', () => { @@ -173,6 +166,7 @@ describe('Dashboards list', () => { }); it('should bulk delete correctly', () => { + interceptBulkDelete(); toggleBulkSelect(); // bulk deletes in card-view @@ -182,7 +176,8 @@ describe('Dashboards list', () => { cy.getBySel('styled-card').eq(0).contains('1 - Sample dashboard').click(); cy.getBySel('styled-card').eq(1).contains('2 - Sample dashboard').click(); cy.getBySel('bulk-select-action').eq(0).contains('Delete').click(); - confirmDelete(true); + confirmDelete(); + cy.wait('@bulkDelete'); cy.getBySel('styled-card') .eq(0) .should('not.contain', '1 - Sample dashboard'); @@ -197,7 +192,8 @@ describe('Dashboards list', () => { cy.get('[data-test="table-row"] input[type="checkbox"]').eq(0).click(); cy.get('[data-test="table-row"] input[type="checkbox"]').eq(1).click(); cy.getBySel('bulk-select-action').eq(0).contains('Delete').click(); - confirmDelete(true); + confirmDelete(); + cy.wait('@bulkDelete'); cy.getBySel('table-row') .eq(0) .should('not.contain', '3 - Sample dashboard'); @@ -206,36 +202,31 @@ describe('Dashboards list', () => { .should('not.contain', '4 - Sample dashboard'); }); - it.skip('should delete correctly in list mode', () => { - // deletes in list-view - setGridMode('list'); + it.skip('should delete correctly', () => { + interceptDelete(); - cy.getBySel('table-row') - .eq(0) - .contains('4 - Sample dashboard') - .should('exist'); - cy.getBySel('dashboard-list-trash-icon').eq(0).click(); - confirmDelete(); - cy.getBySel('table-row') - .eq(0) - .should('not.contain', '4 - Sample dashboard'); - }); - - it('should delete correctly in card mode', () => { // deletes in card-view setGridMode('card'); orderAlphabetical(); - cy.getBySel('styled-card') - .eq(0) - .contains('1 - Sample dashboard') - .should('exist'); + cy.getBySel('styled-card').eq(0).contains('1 - Sample dashboard'); openMenu(); cy.getBySel('dashboard-card-option-delete-button').click(); confirmDelete(); + cy.wait('@delete'); cy.getBySel('styled-card') .eq(0) .should('not.contain', '1 - Sample dashboard'); + + // deletes in list-view + setGridMode('list'); + cy.getBySel('table-row').eq(0).contains('2 - Sample dashboard'); + cy.getBySel('dashboard-list-trash-icon').eq(0).click(); + confirmDelete(); + cy.wait('@delete'); + cy.getBySel('table-row') + .eq(0) + .should('not.contain', '2 - Sample dashboard'); }); it('should edit correctly', () => { diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json index f8878539a0670..59768e6fdff08 100644 --- a/superset-frontend/package-lock.json +++ b/superset-frontend/package-lock.json @@ -56,7 +56,7 @@ "@visx/xychart": "^3.5.1", "abortcontroller-polyfill": "^1.7.8", "ace-builds": "^1.36.3", - "antd": "4.10.3", + "antd": "^4.10.3", "antd-v5": "npm:antd@^5.18.0", "bootstrap": "^3.4.1", "brace": "^0.11.1", @@ -79,6 +79,8 @@ "geostyler-style": "^7.5.0", "geostyler-wfs-parser": "^2.0.3", "googleapis": "^130.0.0", + "handlebars": "^4.7.8", + "html-webpack-plugin": "^5.6.3", "immer": "^10.1.1", "interweave": "^13.1.0", "jquery": "^3.7.1", @@ -179,7 +181,7 @@ "@storybook/react-webpack5": "8.1.11", "@svgr/webpack": "^8.1.0", "@testing-library/dom": "^8.20.1", - "@testing-library/jest-dom": "^6.5.0", + "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^12.1.5", "@testing-library/react-hooks": "^8.0.1", "@testing-library/user-event": "^12.8.3", @@ -284,6 +286,7 @@ "style-loader": "^4.0.0", "thread-loader": "^4.0.4", "ts-loader": "^9.5.1", + "tsx": "^4.19.2", "typescript": "^4.8.4", "vm-browserify": "^1.1.2", "webpack": "^5.97.1", @@ -5164,6 +5167,23 @@ "node": ">=12" } }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz", + "integrity": "sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@esbuild/openbsd-x64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", @@ -12829,9 +12849,9 @@ } }, "node_modules/@testing-library/jest-dom": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.5.0.tgz", - "integrity": "sha512-xGGHpBXYSHUUr6XsKBfs85TWlYKpTc37cSBBVrXcib2MkHLboWlkClhWF37JKlDb9KEq3dHs+f2xR7XJEWGBxA==", + "version": "6.6.3", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz", + "integrity": "sha512-IteBhl4XqYNkM54f4ejhLRJiZNqcSCoXUOG2CPK7qbD322KjQozM4kHQOfkG2oln9b9HTYqs+Sae8vBATubxxA==", "license": "MIT", "dependencies": { "@adobe/css-tools": "^4.4.0", @@ -16117,6 +16137,8 @@ }, "node_modules/antd": { "version": "4.10.3", + "resolved": "https://registry.npmjs.org/antd/-/antd-4.10.3.tgz", + "integrity": "sha512-J/IZvW15MwTmUxK/AWFkSU51T1Hyn4e0GchJWlIe7+FrPpLoTgLf9/Cx3mgxiooHfE9OfvnYvvRli1VxHH6H0Q==", "license": "MIT", "dependencies": { "@ant-design/colors": "^5.0.0", @@ -26533,8 +26555,11 @@ "license": "ISC" }, "node_modules/fsevents": { - "version": "2.3.2", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, + "hasInstallScript": true, "license": "MIT", "optional": true, "os": [ @@ -51347,6 +51372,457 @@ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" } }, + "node_modules/tsx": { + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.2.tgz", + "integrity": "sha512-pOUl6Vo2LUq/bSa8S5q7b91cgNSjctn9ugq/+Mvow99qW6x/UZYwzxy/3NmqoT66eHYfCVvFvACC58UBPFf28g==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.23.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/tsx/node_modules/@esbuild/aix-ppc64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz", + "integrity": "sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.23.1.tgz", + "integrity": "sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz", + "integrity": "sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.23.1.tgz", + "integrity": "sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz", + "integrity": "sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz", + "integrity": "sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz", + "integrity": "sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz", + "integrity": "sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz", + "integrity": "sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz", + "integrity": "sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ia32": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz", + "integrity": "sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-loong64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz", + "integrity": "sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-mips64el": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz", + "integrity": "sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ppc64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz", + "integrity": "sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-riscv64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz", + "integrity": "sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-s390x": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz", + "integrity": "sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz", + "integrity": "sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/netbsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz", + "integrity": "sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/openbsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz", + "integrity": "sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/sunos-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz", + "integrity": "sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz", + "integrity": "sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-ia32": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz", + "integrity": "sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz", + "integrity": "sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/esbuild": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.1.tgz", + "integrity": "sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.23.1", + "@esbuild/android-arm": "0.23.1", + "@esbuild/android-arm64": "0.23.1", + "@esbuild/android-x64": "0.23.1", + "@esbuild/darwin-arm64": "0.23.1", + "@esbuild/darwin-x64": "0.23.1", + "@esbuild/freebsd-arm64": "0.23.1", + "@esbuild/freebsd-x64": "0.23.1", + "@esbuild/linux-arm": "0.23.1", + "@esbuild/linux-arm64": "0.23.1", + "@esbuild/linux-ia32": "0.23.1", + "@esbuild/linux-loong64": "0.23.1", + "@esbuild/linux-mips64el": "0.23.1", + "@esbuild/linux-ppc64": "0.23.1", + "@esbuild/linux-riscv64": "0.23.1", + "@esbuild/linux-s390x": "0.23.1", + "@esbuild/linux-x64": "0.23.1", + "@esbuild/netbsd-x64": "0.23.1", + "@esbuild/openbsd-arm64": "0.23.1", + "@esbuild/openbsd-x64": "0.23.1", + "@esbuild/sunos-x64": "0.23.1", + "@esbuild/win32-arm64": "0.23.1", + "@esbuild/win32-ia32": "0.23.1", + "@esbuild/win32-x64": "0.23.1" + } + }, "node_modules/tuf-js": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tuf-js/-/tuf-js-2.2.1.tgz", @@ -55644,6 +56120,7 @@ "@types/react": "*", "@types/react-loadable": "*", "@types/tinycolor2": "*", + "antd-v5": "npm:antd@^5.18.0", "react": "^16.13.1", "react-loadable": "^5.5.0", "tinycolor2": "*" @@ -61675,6 +62152,13 @@ "dev": true, "optional": true }, + "@esbuild/openbsd-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz", + "integrity": "sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q==", + "dev": true, + "optional": true + }, "@esbuild/openbsd-x64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", @@ -69213,9 +69697,9 @@ } }, "@testing-library/jest-dom": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.5.0.tgz", - "integrity": "sha512-xGGHpBXYSHUUr6XsKBfs85TWlYKpTc37cSBBVrXcib2MkHLboWlkClhWF37JKlDb9KEq3dHs+f2xR7XJEWGBxA==", + "version": "6.6.3", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz", + "integrity": "sha512-IteBhl4XqYNkM54f4ejhLRJiZNqcSCoXUOG2CPK7qbD322KjQozM4kHQOfkG2oln9b9HTYqs+Sae8vBATubxxA==", "requires": { "@adobe/css-tools": "^4.4.0", "aria-query": "^5.0.0", @@ -71676,6 +72160,8 @@ }, "antd": { "version": "4.10.3", + "resolved": "https://registry.npmjs.org/antd/-/antd-4.10.3.tgz", + "integrity": "sha512-J/IZvW15MwTmUxK/AWFkSU51T1Hyn4e0GchJWlIe7+FrPpLoTgLf9/Cx3mgxiooHfE9OfvnYvvRli1VxHH6H0Q==", "requires": { "@ant-design/colors": "^5.0.0", "@ant-design/icons": "^4.3.0", @@ -78595,7 +79081,9 @@ "version": "1.0.0" }, "fsevents": { - "version": "2.3.2", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "optional": true }, @@ -94167,6 +94655,212 @@ "tslib": "^1.8.1" } }, + "tsx": { + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.2.tgz", + "integrity": "sha512-pOUl6Vo2LUq/bSa8S5q7b91cgNSjctn9ugq/+Mvow99qW6x/UZYwzxy/3NmqoT66eHYfCVvFvACC58UBPFf28g==", + "dev": true, + "requires": { + "esbuild": "~0.23.0", + "fsevents": "~2.3.3", + "get-tsconfig": "^4.7.5" + }, + "dependencies": { + "@esbuild/aix-ppc64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz", + "integrity": "sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ==", + "dev": true, + "optional": true + }, + "@esbuild/android-arm": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.23.1.tgz", + "integrity": "sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ==", + "dev": true, + "optional": true + }, + "@esbuild/android-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz", + "integrity": "sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw==", + "dev": true, + "optional": true + }, + "@esbuild/android-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.23.1.tgz", + "integrity": "sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg==", + "dev": true, + "optional": true + }, + "@esbuild/darwin-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz", + "integrity": "sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q==", + "dev": true, + "optional": true + }, + "@esbuild/darwin-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz", + "integrity": "sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw==", + "dev": true, + "optional": true + }, + "@esbuild/freebsd-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz", + "integrity": "sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA==", + "dev": true, + "optional": true + }, + "@esbuild/freebsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz", + "integrity": "sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g==", + "dev": true, + "optional": true + }, + "@esbuild/linux-arm": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz", + "integrity": "sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ==", + "dev": true, + "optional": true + }, + "@esbuild/linux-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz", + "integrity": "sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g==", + "dev": true, + "optional": true + }, + "@esbuild/linux-ia32": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz", + "integrity": "sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ==", + "dev": true, + "optional": true + }, + "@esbuild/linux-loong64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz", + "integrity": "sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw==", + "dev": true, + "optional": true + }, + "@esbuild/linux-mips64el": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz", + "integrity": "sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q==", + "dev": true, + "optional": true + }, + "@esbuild/linux-ppc64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz", + "integrity": "sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw==", + "dev": true, + "optional": true + }, + "@esbuild/linux-riscv64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz", + "integrity": "sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA==", + "dev": true, + "optional": true + }, + "@esbuild/linux-s390x": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz", + "integrity": "sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw==", + "dev": true, + "optional": true + }, + "@esbuild/linux-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz", + "integrity": "sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ==", + "dev": true, + "optional": true + }, + "@esbuild/netbsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz", + "integrity": "sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA==", + "dev": true, + "optional": true + }, + "@esbuild/openbsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz", + "integrity": "sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA==", + "dev": true, + "optional": true + }, + "@esbuild/sunos-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz", + "integrity": "sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA==", + "dev": true, + "optional": true + }, + "@esbuild/win32-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz", + "integrity": "sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A==", + "dev": true, + "optional": true + }, + "@esbuild/win32-ia32": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz", + "integrity": "sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ==", + "dev": true, + "optional": true + }, + "@esbuild/win32-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz", + "integrity": "sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg==", + "dev": true, + "optional": true + }, + "esbuild": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.1.tgz", + "integrity": "sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==", + "dev": true, + "requires": { + "@esbuild/aix-ppc64": "0.23.1", + "@esbuild/android-arm": "0.23.1", + "@esbuild/android-arm64": "0.23.1", + "@esbuild/android-x64": "0.23.1", + "@esbuild/darwin-arm64": "0.23.1", + "@esbuild/darwin-x64": "0.23.1", + "@esbuild/freebsd-arm64": "0.23.1", + "@esbuild/freebsd-x64": "0.23.1", + "@esbuild/linux-arm": "0.23.1", + "@esbuild/linux-arm64": "0.23.1", + "@esbuild/linux-ia32": "0.23.1", + "@esbuild/linux-loong64": "0.23.1", + "@esbuild/linux-mips64el": "0.23.1", + "@esbuild/linux-ppc64": "0.23.1", + "@esbuild/linux-riscv64": "0.23.1", + "@esbuild/linux-s390x": "0.23.1", + "@esbuild/linux-x64": "0.23.1", + "@esbuild/netbsd-x64": "0.23.1", + "@esbuild/openbsd-arm64": "0.23.1", + "@esbuild/openbsd-x64": "0.23.1", + "@esbuild/sunos-x64": "0.23.1", + "@esbuild/win32-arm64": "0.23.1", + "@esbuild/win32-ia32": "0.23.1", + "@esbuild/win32-x64": "0.23.1" + } + } + } + }, "tuf-js": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tuf-js/-/tuf-js-2.2.1.tgz", diff --git a/superset-frontend/package.json b/superset-frontend/package.json index 7b8aee659123d..b8fff7fee2202 100644 --- a/superset-frontend/package.json +++ b/superset-frontend/package.json @@ -44,6 +44,7 @@ "build-storybook": "storybook build", "build-translation": "scripts/po2json.sh", "bundle-stats": "cross-env BUNDLE_ANALYZER=true npm run build && npx open-cli ../superset/static/stats/statistics.html", + "compile-less": "tsx ./scripts/compileLess.ts", "core:cover": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=4096\" jest --coverage --coverageThreshold='{\"global\":{\"statements\":100,\"branches\":100,\"functions\":100,\"lines\":100}}' --collectCoverageFrom='[\"packages/**/src/**/*.{js,ts}\", \"!packages/superset-ui-demo/**/*\"]' packages", "cover": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=4096\" jest --coverage", "dev": "webpack --mode=development --color --watch", @@ -70,7 +71,7 @@ "storybook": "cross-env NODE_ENV=development BABEL_ENV=development storybook dev -p 6006", "tdd": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=4096\" jest --watch", "test": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=4096\" jest --max-workers=50%", - "type": "tsc --noEmit", + "type": "tsc --project tsconfig.json --noEmit", "update-maps": "jupyter nbconvert --to notebook --execute --inplace 'plugins/legacy-plugin-chart-country-map/scripts/Country Map GeoJSON Generator.ipynb' -Xfrozen_modules=off", "validate-release": "../RELEASING/validate_this_release.sh" }, @@ -123,7 +124,7 @@ "@visx/xychart": "^3.5.1", "abortcontroller-polyfill": "^1.7.8", "ace-builds": "^1.36.3", - "antd": "4.10.3", + "antd": "^4.10.3", "antd-v5": "npm:antd@^5.18.0", "bootstrap": "^3.4.1", "brace": "^0.11.1", @@ -146,6 +147,8 @@ "geostyler-style": "^7.5.0", "geostyler-wfs-parser": "^2.0.3", "googleapis": "^130.0.0", + "html-webpack-plugin": "^5.6.3", + "handlebars": "^4.7.8", "immer": "^10.1.1", "interweave": "^13.1.0", "jquery": "^3.7.1", @@ -246,7 +249,7 @@ "@storybook/react-webpack5": "8.1.11", "@svgr/webpack": "^8.1.0", "@testing-library/dom": "^8.20.1", - "@testing-library/jest-dom": "^6.5.0", + "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^12.1.5", "@testing-library/react-hooks": "^8.0.1", "@testing-library/user-event": "^12.8.3", @@ -351,6 +354,7 @@ "style-loader": "^4.0.0", "thread-loader": "^4.0.4", "ts-loader": "^9.5.1", + "tsx": "^4.19.2", "typescript": "^4.8.4", "vm-browserify": "^1.1.2", "webpack": "^5.97.1", diff --git a/superset-frontend/packages/generator-superset/generators/plugin-chart/templates/src/MyChart.erb b/superset-frontend/packages/generator-superset/generators/plugin-chart/templates/src/MyChart.erb index c5b8583de134b..136158ea5c441 100644 --- a/superset-frontend/packages/generator-superset/generators/plugin-chart/templates/src/MyChart.erb +++ b/superset-frontend/packages/generator-superset/generators/plugin-chart/templates/src/MyChart.erb @@ -25,29 +25,14 @@ import { <%= packageLabel %>Props, <%= packageLabel %>StylesProps } from './type // Theming variables are provided for your use via a ThemeProvider // imported from @superset-ui/core. For variables available, please visit -// https://github.com/apache-superset/superset-ui/blob/master/packages/superset-ui-core/src/style/index.ts +// https://github.com/apache-superset/superset-ui/blob/master/packages/superset-ui-core/src/theme/index.ts const Styles = styled.div<<%= packageLabel %>StylesProps>` - background-color: ${({ theme }) => theme.colors.secondary.light2}; + background-color: ${({ theme }) => theme.colors.primary.light2}; padding: ${({ theme }) => theme.gridUnit * 4}px; border-radius: ${({ theme }) => theme.gridUnit * 2}px; height: ${({ height }) => height}px; width: ${({ width }) => width}px; - - h3 { - /* You can use your props to control CSS! */ - margin-top: 0; - margin-bottom: ${({ theme }) => theme.gridUnit * 3}px; - font-size: ${({ theme, headerFontSize }) => - theme.typography.sizes[headerFontSize]}px; - font-weight: ${({ theme, boldText }) => - theme.typography.weights[boldText ? 'bold' : 'normal']}; - } - - pre { - height: ${({ theme, headerFontSize, height }) => - height - theme.gridUnit * 12 - theme.typography.sizes[headerFontSize]}px; - } `; /** diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/CertifiedIconWithTooltip.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/CertifiedIconWithTooltip.tsx index 5468d66139c23..6124834c573bd 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/CertifiedIconWithTooltip.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/CertifiedIconWithTooltip.tsx @@ -27,7 +27,7 @@ interface CertifiedIconWithTooltipProps { } const StyledDiv = styled.div` - margin-bottom: ${({ theme }) => theme.gridUnit * 2}px; + margin-bottom: ${({ theme }) => theme.sizeUnit * 2}px; `; function CertifiedIconWithTooltip({ @@ -58,7 +58,7 @@ function CertifiedIconWithTooltip({ > diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx index db449b3450ef6..a9a3d1bdaf7f5 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx @@ -40,7 +40,7 @@ const StyleOverrides = styled.span` display: flex; align-items: center; svg { - margin-right: ${({ theme }) => theme.gridUnit}px; + margin-right: ${({ theme }) => theme.sizeUnit}px; } `; @@ -82,7 +82,7 @@ export function ColumnOption({ css` - margin-right: ${theme.gridUnit}px; + margin-right: ${theme.sizeUnit}px; `} ref={labelRef} > diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnTypeLabel/ColumnTypeLabel.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnTypeLabel/ColumnTypeLabel.tsx index 6c655d330a84d..ffad85f98dd3f 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnTypeLabel/ColumnTypeLabel.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnTypeLabel/ColumnTypeLabel.tsx @@ -37,9 +37,9 @@ const TypeIconWrapper = styled.div` display: flex; justify-content: center; align-items: center; - width: ${theme.gridUnit * 6}px; - height: ${theme.gridUnit * 6}px; - margin-right: ${theme.gridUnit}px; + width: ${theme.sizeUnit * 6}px; + height: ${theme.sizeUnit * 6}px; + margin-right: ${theme.sizeUnit}px; && svg { margin-right: 0; diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/ControlSubSectionHeader.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/ControlSubSectionHeader.tsx index 731b34b6af5b0..ab6e600bdcb8b 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/ControlSubSectionHeader.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/ControlSubSectionHeader.tsx @@ -19,8 +19,8 @@ import { styled } from '@superset-ui/core'; export const ControlSubSectionHeader = styled.div` - font-weight: ${({ theme }) => theme.typography.weights.bold}; - font-size: ${({ theme }) => theme.typography.sizes.s}; - margin-bottom: ${({ theme }) => theme.gridUnit}px; + font-weight: ${({ theme }) => theme.fontWeightStrong}; + font-size: ${({ theme }) => theme.fontSizeSM}; + margin-bottom: ${({ theme }) => theme.sizeUnit}px; `; export default ControlSubSectionHeader; diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/MetricOption.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/MetricOption.tsx index c424cde518e26..cb54167df08cf 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/MetricOption.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/MetricOption.tsx @@ -37,7 +37,7 @@ const FlexRowContainer = styled.div` display: flex; > svg { - margin-right: ${({ theme }) => theme.gridUnit}px; + margin-right: ${({ theme }) => theme.sizeUnit}px; } `; @@ -73,7 +73,7 @@ export function MetricOption({ css` - margin-right: ${theme.gridUnit}px; + margin-right: ${theme.sizeUnit}px; `} ref={labelRef} > diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/SQLPopover.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/SQLPopover.tsx index a848a2e9fc1f0..359089c15a1bf 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/SQLPopover.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/SQLPopover.tsx @@ -26,10 +26,10 @@ import { css, styled, useTheme, t } from '@superset-ui/core'; const StyledCalculatorIcon = styled(CalculatorOutlined)` ${({ theme }) => css` color: ${theme.colors.grayscale.base}; - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; & svg { - margin-left: ${theme.gridUnit}px; - margin-right: ${theme.gridUnit}px; + margin-left: ${theme.sizeUnit}px; + margin-right: ${theme.sizeUnit}px; } `} `; @@ -66,8 +66,8 @@ export const SQLPopover = (props: PopoverProps & { sqlExpression: string }) => { wrapEnabled style={{ border: `1px solid ${theme.colors.grayscale.light2}`, - background: theme.colors.secondary.light5, - maxWidth: theme.gridUnit * 100, + background: theme.colorPrimaryBg, + maxWidth: theme.sizeUnit * 100, }} /> } diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/Tooltip.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/Tooltip.tsx index e89944121b8eb..87c158b48be26 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/Tooltip.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/Tooltip.tsx @@ -37,10 +37,10 @@ export const Tooltip = ({ return ( css` display: flex; flex-direction: column; - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; line-height: 1.2; &:not(:last-of-type) { - margin-bottom: ${theme.gridUnit * 2}px; + margin-bottom: ${theme.sizeUnit * 2}px; } &:last-of-type { display: -webkit-box; @@ -43,7 +43,7 @@ const TooltipSectionWrapper = styled.div` const TooltipSectionLabel = styled.span` ${({ theme }) => css` - font-weight: ${theme.typography.weights.bold}; + font-weight: ${theme.fontWeightStrong}; `} `; diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx index cd2a4352d1744..4191aa5b41330 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx @@ -55,17 +55,17 @@ export default function RadioButtonControl({ }, '.control-label': { color: theme.colors.grayscale.base, - marginBottom: theme.gridUnit, + marginBottom: theme.sizeUnit, }, '.control-label + .btn-group': { marginTop: '1px', }, '.btn-group .btn-default': { - color: theme.colors.grayscale.dark1, + color: theme.colorText, }, '.btn-group .btn.active': { background: theme.colors.grayscale.light4, - fontWeight: theme.typography.weights.bold, + fontWeight: theme.fontWeightStrong, boxShadow: 'none', }, }} diff --git a/superset-frontend/packages/superset-ui-core/package.json b/superset-frontend/packages/superset-ui-core/package.json index 227a5231893c5..3f20a4bde7dba 100644 --- a/superset-frontend/packages/superset-ui-core/package.json +++ b/superset-frontend/packages/superset-ui-core/package.json @@ -70,6 +70,7 @@ "timezone-mock": "1.3.6" }, "peerDependencies": { + "antd-v5": "npm:antd@^5.18.0", "@emotion/cache": "^11.4.0", "@emotion/react": "^11.4.1", "@emotion/styled": "^11.3.0", diff --git a/superset-frontend/packages/superset-ui-core/src/chart/components/FallbackComponent.tsx b/superset-frontend/packages/superset-ui-core/src/chart/components/FallbackComponent.tsx index 60f6848f882f2..d960084b2fa1b 100644 --- a/superset-frontend/packages/superset-ui-core/src/chart/components/FallbackComponent.tsx +++ b/superset-frontend/packages/superset-ui-core/src/chart/components/FallbackComponent.tsx @@ -18,7 +18,7 @@ */ import { t } from '@superset-ui/core'; -import { SupersetTheme } from '../../style'; +import { SupersetTheme } from '../..'; import { FallbackPropsWithDimension } from './SuperChart'; export type Props = FallbackPropsWithDimension; diff --git a/superset-frontend/packages/superset-ui-core/src/chart/components/NoResultsComponent.tsx b/superset-frontend/packages/superset-ui-core/src/chart/components/NoResultsComponent.tsx index 73e8df625843e..3bcb3e3a89a7a 100644 --- a/superset-frontend/packages/superset-ui-core/src/chart/components/NoResultsComponent.tsx +++ b/superset-frontend/packages/superset-ui-core/src/chart/components/NoResultsComponent.tsx @@ -18,7 +18,7 @@ */ import { CSSProperties } from 'react'; -import { css, styled } from '../../style'; +import { css, styled } from '../../theme'; import { t } from '../../translation'; const MESSAGE_STYLES: CSSProperties = { maxWidth: 800 }; @@ -36,16 +36,16 @@ const Container = styled.div<{ text-align: center; height: ${height}px; width: ${width}px; - padding: ${theme.gridUnit * 4}px; + padding: ${theme.sizeUnit * 4}px; & .no-results-title { - font-size: ${theme.typography.sizes.l}px; - font-weight: ${theme.typography.weights.bold}; - padding-bottom: ${theme.gridUnit * 2}; + font-size: ${theme.fontSizeLG}px; + font-weight: ${theme.fontWeightStrong}; + padding-bottom: ${theme.sizeUnit * 2}; } & .no-results-body { - font-size: ${theme.typography.sizes.m}px; + font-size: ${theme.fontSize}px; } `} `; diff --git a/superset-frontend/packages/superset-ui-core/src/chart/models/ChartProps.ts b/superset-frontend/packages/superset-ui-core/src/chart/models/ChartProps.ts index 829440133a32c..2eecb73d1cb16 100644 --- a/superset-frontend/packages/superset-ui-core/src/chart/models/ChartProps.ts +++ b/superset-frontend/packages/superset-ui-core/src/chart/models/ChartProps.ts @@ -37,7 +37,7 @@ import { SetDataMaskHook, } from '../types/Base'; import { QueryData, DataRecordFilters } from '..'; -import { SupersetTheme } from '../../style'; +import { SupersetTheme } from '../../theme'; // TODO: more specific typing for these fields of ChartProps type AnnotationData = PlainObject; diff --git a/superset-frontend/packages/superset-ui-core/src/index.ts b/superset-frontend/packages/superset-ui-core/src/index.ts index 7258a3b648286..99e9b5184333b 100644 --- a/superset-frontend/packages/superset-ui-core/src/index.ts +++ b/superset-frontend/packages/superset-ui-core/src/index.ts @@ -28,7 +28,7 @@ export * from './number-format'; export * from './time-format'; export * from './dimension'; export * from './color'; -export * from './style'; +export * from './theme'; export * from './validator'; export * from './chart'; export * from './chart-composition'; diff --git a/superset-frontend/packages/superset-ui-core/src/style/index.tsx b/superset-frontend/packages/superset-ui-core/src/style/index.tsx deleted file mode 100644 index c4964172be622..0000000000000 --- a/superset-frontend/packages/superset-ui-core/src/style/index.tsx +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import emotionStyled from '@emotion/styled'; -import { useTheme as useThemeBasic } from '@emotion/react'; -import createCache from '@emotion/cache'; - -export { - css, - keyframes, - jsx, - ThemeProvider, - CacheProvider as EmotionCacheProvider, - withTheme, -} from '@emotion/react'; -export { default as createEmotionCache } from '@emotion/cache'; - -declare module '@emotion/react' { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - export interface Theme extends SupersetTheme {} -} - -export function useTheme() { - const theme = useThemeBasic(); - // in the case there is no theme, useTheme returns an empty object - if (Object.keys(theme).length === 0 && theme.constructor === Object) { - throw new Error( - 'useTheme() could not find a ThemeContext. The component is likely missing from the app.', - ); - } - return theme; -} - -export const emotionCache = createCache({ - key: 'superset', -}); - -export const styled = emotionStyled; - -const defaultTheme = { - borderRadius: 4, - colors: { - text: { - label: '#879399', - help: '#737373', - }, - primary: { - base: '#20A7C9', - dark1: '#1A85A0', - dark2: '#156378', - light1: '#79CADE', - light2: '#A5DAE9', - light3: '#D2EDF4', - light4: '#E9F6F9', - light5: '#F3F8FA', - }, - secondary: { - base: '#444E7C', - dark1: '#363E63', - dark2: '#282E4A', - dark3: '#1B1F31', - light1: '#8E94B0', - light2: '#B4B8CA', - light3: '#D9DBE4', - light4: '#ECEEF2', - light5: '#F5F5F8', - }, - grayscale: { - base: '#666666', - dark1: '#323232', - dark2: '#000000', - light1: '#B2B2B2', - light2: '#E0E0E0', - light3: '#F0F0F0', - light4: '#F7F7F7', - light5: '#FFFFFF', - }, - error: { - base: '#E04355', - dark1: '#A7323F', - dark2: '#6F212A', - light1: '#EFA1AA', - light2: '#FAEDEE', - }, - warning: { - base: '#FCC700', - dark1: '#BC9501', - dark2: '#7D6300', - light1: '#FDE380', - light2: '#FEF9E6', - }, - success: { - base: '#5AC189', - dark1: '#439066', - dark2: '#2B6144', - light1: '#ACE1C4', - light2: '#EEF8F3', - }, - info: { - base: '#66BCFE', - dark1: '#4D8CBE', - dark2: '#315E7E', - light1: '#B3DEFE', - light2: '#EFF8FE', - }, - }, - opacity: { - light: '10%', - mediumLight: '35%', - mediumHeavy: '60%', - heavy: '80%', - }, - typography: { - families: { - sansSerif: `'Inter', Helvetica, Arial`, - serif: `Georgia, 'Times New Roman', Times, serif`, - monospace: `'Fira Code', 'Courier New', monospace`, - }, - weights: { - light: 200, - normal: 400, - medium: 500, - bold: 600, - }, - sizes: { - xxs: 9, - xs: 10, - s: 12, - m: 14, - l: 16, - xl: 21, - xxl: 28, - }, - }, - zIndex: { - aboveDashboardCharts: 10, - dropdown: 11, - max: 3000, - }, - transitionTiming: 0.3, - gridUnit: 4, - brandIconMaxWidth: 37, -}; - -export type SupersetTheme = typeof defaultTheme; - -export interface SupersetThemeProps { - theme: SupersetTheme; -} - -export const supersetTheme = defaultTheme; diff --git a/superset-frontend/packages/superset-ui-core/src/theme/Theme.test.tsx b/superset-frontend/packages/superset-ui-core/src/theme/Theme.test.tsx new file mode 100644 index 0000000000000..15fcfa5704209 --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/src/theme/Theme.test.tsx @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { render } from '@testing-library/react'; +import { Theme } from './Theme'; +import '@testing-library/jest-dom'; + +describe('Theme Class', () => { + test('should initialize with default system colors', () => { + const theme = Theme.fromSeed({}, false); + const themeConfig = theme.theme; + expect(themeConfig.colorBgElevated).toBe('#ffffff'); + expect(themeConfig.colorText).toBe('rgba(0, 0, 0, 0.88)'); + }); + + test('should apply custom system colors and dark mode', () => { + const theme = Theme.fromSeed({}, true); + const themeConfig = theme.theme; + expect(themeConfig.colorText).toBe('rgba(255, 255, 255, 0.85)'); + }); +}); + +describe('SupersetThemeProvider Component', () => { + test('should render children without errors', () => { + const theme = Theme.fromSeed({}, true); + const { getByText } = render( + +
Test Child
+
, + ); + expect(getByText('Test Child')).toBeInTheDocument(); + }); +}); diff --git a/superset-frontend/packages/superset-ui-core/src/theme/Theme.tsx b/superset-frontend/packages/superset-ui-core/src/theme/Theme.tsx new file mode 100644 index 0000000000000..6a807ed840359 --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/src/theme/Theme.tsx @@ -0,0 +1,613 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +// eslint-disable-next-line no-restricted-syntax +import React from 'react'; +import { + theme as antdThemeImport, + ThemeConfig as AntdThemeConfig, + ConfigProvider, +} from 'antd-v5'; +import tinycolor from 'tinycolor2'; + +import { + ThemeProvider as EmotionThemeProvider, + CacheProvider as EmotionCacheProvider, +} from '@emotion/react'; +import createCache from '@emotion/cache'; +// import { merge } from 'lodash'; + +type AntdTokens = ReturnType; +/* eslint-disable theme-colors/no-literal-colors */ + +interface SystemColors { + colorPrimary: string; + colorError: string; + colorWarning: string; + colorSuccess: string; + colorInfo: string; +} +interface ColorVariants { + bg: string; + border: string; + hover: string; + active: string; + textHover: string; + text: string; + borderHover: string; + bgHover: string; + textActive: string; +} + +interface ColorVariations { + base: string; + light1: string; + light2: string; + light3: string; + light4: string; + light5: string; + dark1: string; + dark2: string; + dark3: string; + dark4: string; + dark5: string; +} + +interface ThemeColors { + primary: ColorVariations; + error: ColorVariations; + warning: ColorVariations; + success: ColorVariations; + info: ColorVariations; + grayscale: ColorVariations; +} + +// Tokens to be removed +interface LegacySupersetTheme { + // Old colors structure with light/dark semantics still heavily referenced in code base + // TODO: replace/realign with antd-type tokens + colors: ThemeColors; + transitionTiming: number; +} + +interface SupersetSpecificTokens { + // Brand-related + brandIconMaxWidth: number; + + // Font-related + fontSizeXS: string; + fontSizeXXL: string; + fontWeightNormal: string; + fontWeightLight: string; + fontWeightMedium: string; +} + +const allowedAntdTokens = [ + 'borderRadius', + 'borderRadiusLG', + 'borderRadiusOuter', + 'borderRadiusSM', + 'borderRadiusXS', + 'boxShadow', + 'boxShadowCard', + 'boxShadowDrawerDown', + 'boxShadowDrawerLeft', + 'boxShadowDrawerRight', + 'boxShadowDrawerUp', + 'boxShadowPopoverArrow', + 'boxShadowSecondary', + 'boxShadowTabsOverflowBottom', + 'boxShadowTabsOverflowLeft', + 'boxShadowTabsOverflowRight', + 'boxShadowTabsOverflowTop', + 'boxShadowTertiary', + 'colorError', + 'colorErrorActive', + 'colorErrorBg', + 'colorErrorBgActive', + 'colorErrorBgHover', + 'colorErrorBorder', + 'colorErrorBorderHover', + 'colorErrorHover', + 'colorErrorOutline', + 'colorErrorText', + 'colorErrorTextActive', + 'colorErrorTextHover', + 'colorPrimary', + 'colorPrimaryActive', + 'colorPrimaryBg', + 'colorPrimaryBgHover', + 'colorPrimaryBorder', + 'colorPrimaryBorderHover', + 'colorPrimaryHover', + 'colorPrimaryText', + 'colorPrimaryTextActive', + 'colorPrimaryTextHover', + 'colorSuccess', + 'colorSuccessActive', + 'colorSuccessBg', + 'colorSuccessBgHover', + 'colorSuccessBorder', + 'colorSuccessBorderHover', + 'colorSuccessHover', + 'colorSuccessText', + 'colorSuccessTextActive', + 'colorSuccessTextHover', + 'colorBgBase', + 'colorBgBlur', + 'colorBgContainer', + 'colorBgContainerDisabled', + 'colorBgElevated', + 'colorBgLayout', + 'colorBgMask', + 'colorBgSpotlight', + 'colorBgTextActive', + 'colorBgTextHover', + 'colorBorder', + 'colorBorderBg', + 'colorBorderSecondary', + 'colorFill', + 'colorFillAlter', + 'colorFillContent', + 'colorFillContentHover', + 'colorFillQuaternary', + 'colorFillSecondary', + 'colorFillTertiary', + 'colorHighlight', + 'colorIcon', + 'colorIconHover', + 'colorInfo', + 'colorInfoActive', + 'colorInfoBg', + 'colorInfoBgHover', + 'colorInfoBorder', + 'colorInfoBorderHover', + 'colorInfoHover', + 'colorInfoText', + 'colorInfoTextActive', + 'colorInfoTextHover', + 'colorLink', + 'colorLinkActive', + 'colorLinkHover', + 'colorSplit', + 'colorText', + 'colorTextBase', + 'colorTextDescription', + 'colorTextDisabled', + 'colorTextHeading', + 'colorTextLabel', + 'colorTextLightSolid', + 'colorTextPlaceholder', + 'colorTextQuaternary', + 'colorTextSecondary', + 'colorTextTertiary', + 'colorWarning', + 'colorWarningActive', + 'colorWarningBg', + 'colorWarningBgHover', + 'colorWarningBorder', + 'colorWarningBorderHover', + 'colorWarningHover', + 'colorWarningOutline', + 'colorWarningText', + 'colorWarningTextActive', + 'colorWarningTextHover', + 'colorWhite', + 'controlHeight', + 'controlHeightLG', + 'controlHeightSM', + 'controlHeightXS', + 'controlInteractiveSize', + 'controlItemBgActive', + 'controlItemBgActiveDisabled', + 'controlItemBgActiveHover', + 'controlItemBgHover', + 'controlOutline', + 'controlOutlineWidth', + 'controlPaddingHorizontal', + 'controlPaddingHorizontalSM', + 'controlTmpOutline', + 'fontFamily', + 'fontFamilyCode', + 'fontHeight', + 'fontHeightLG', + 'fontHeightSM', + 'fontSize', + 'fontSizeHeading1', + 'fontSizeHeading2', + 'fontSizeHeading3', + 'fontSizeHeading4', + 'fontSizeHeading5', + 'fontSizeIcon', + 'fontSizeLG', + 'fontSizeSM', + 'fontSizeXL', + 'fontWeightStrong', + 'lineHeight', + 'lineHeightHeading1', + 'lineHeightHeading2', + 'lineHeightHeading3', + 'lineHeightHeading4', + 'lineHeightHeading5', + 'lineHeightLG', + 'lineHeightSM', + 'lineType', + 'lineWidth', + 'lineWidthBold', + 'lineWidthFocus', + 'linkDecoration', + 'linkFocusDecoration', + 'linkHoverDecoration', + 'margin', + 'marginLG', + 'marginMD', + 'marginSM', + 'marginXL', + 'marginXS', + 'marginXXL', + 'marginXXS', + 'motion', + 'motionBase', + 'motionDurationFast', + 'motionDurationMid', + 'motionDurationSlow', + 'motionEaseInBack', + 'motionEaseInOut', + 'motionEaseInOutCirc', + 'motionEaseInQuint', + 'motionEaseOut', + 'motionEaseOutBack', + 'motionEaseOutCirc', + 'motionEaseOutQuint', + 'motionUnit', + 'opacityImage', + 'opacityLoading', + 'padding', + 'paddingContentHorizontal', + 'paddingContentHorizontalLG', + 'paddingContentHorizontalSM', + 'paddingContentVertical', + 'paddingContentVerticalLG', + 'paddingContentVerticalSM', + 'paddingLG', + 'paddingMD', + 'paddingSM', + 'paddingXL', + 'paddingXS', + 'paddingXXS', + 'screenLG', + 'screenLGMax', + 'screenLGMin', + 'screenMD', + 'screenMDMax', + 'screenMDMin', + 'screenSM', + 'screenSMMax', + 'screenSMMin', + 'screenXL', + 'screenXLMax', + 'screenXLMin', + 'screenXS', + 'screenXSMax', + 'screenXSMin', + 'screenXXL', + 'screenXXLMin', + 'size', + 'sizeLG', + 'sizeMD', + 'sizeMS', + 'sizePopupArrow', + 'sizeSM', + 'sizeStep', + 'sizeUnit', + 'sizeXL', + 'sizeXS', + 'sizeXXL', + 'sizeXXS', + 'wireframe', + 'zIndexBase', + 'zIndexPopupBase', +] as const; + +// Playing some tricks to preserve token types from antd while creating a subset +// 1. create a type from the array +type AllowedAntdTokenKeys = Extract< + (typeof allowedAntdTokens)[number], + keyof AntdTokens +>; +// 2. derive the type dynamically +export type SharedAntdTokens = Pick; + +export type SupersetTheme = LegacySupersetTheme & + SharedAntdTokens & + SupersetSpecificTokens; + +export class Theme { + theme: SupersetTheme; + + private static readonly defaultTokens = { + // Default colors + colorPrimary: '#20a7c9', + colorError: '#e04355', + colorWarning: '#fcc700', + colorSuccess: '#5ac189', + colorInfo: '#66bcfe', + + // Forcing some default tokens + fontFamily: `'Inter', Helvetica, Arial`, + fontFamilyCode: `'Fira Code', 'Courier New', monospace`, + + // Extra tokens + transitionTiming: 0.3, + brandIconMaxWidth: 37, + fontSizeXS: '8', + fontSizeXXL: '28', + fontWeightNormal: '400', + fontWeightLight: '300', + fontWeightMedium: '500', + }; + + private antdConfig: AntdThemeConfig; + + private constructor() { + this.updateTheme = this.updateTheme.bind(this); + this.SupersetThemeProvider = this.SupersetThemeProvider.bind(this); + } + + static fromSeed(seed?: Partial, isDark = false): Theme { + const theme = new Theme(); + theme.setThemeFromSeed(seed || {}, isDark); + return theme; + } + + static fromAntdConfig(antdConfig: AntdThemeConfig): Theme { + const theme = new Theme(); + theme.setThemeFromAntdConfig(antdConfig); + return theme; + } + + private static genColorVariations( + color: string, + isDark: boolean, + ): ColorVariations { + const bg = isDark ? '#FFF' : '#000'; + const fg = isDark ? '#000' : '#FFF'; + const adjustColor = (color: string, perc: number, target: string): string => + tinycolor.mix(color, target, perc).toHexString(); + return { + base: color, + light1: adjustColor(color, 20, fg), + light2: adjustColor(color, 45, fg), + light3: adjustColor(color, 70, fg), + light4: adjustColor(color, 90, fg), + light5: adjustColor(color, 95, fg), + dark1: adjustColor(color, 10, bg), + dark2: adjustColor(color, 20, bg), + dark3: adjustColor(color, 40, bg), + dark4: adjustColor(color, 60, bg), + dark5: adjustColor(color, 80, bg), + }; + } + + private static getColors( + systemColors: SystemColors, + isDark: boolean, + ): ThemeColors { + const sc = systemColors; + return { + primary: Theme.genColorVariations(sc.colorPrimary, isDark), + error: Theme.genColorVariations(sc.colorError, isDark), + warning: Theme.genColorVariations(sc.colorWarning, isDark), + success: Theme.genColorVariations(sc.colorSuccess, isDark), + info: Theme.genColorVariations(sc.colorInfo, isDark), + grayscale: Theme.genColorVariations('#666', isDark), + }; + } + + private static augmentSeedWithDefaults( + seed: Partial, + ): Partial { + return { + ...Theme.defaultTokens, + ...seed, + }; + } + + private static getSystemColors(antdTokens: SharedAntdTokens): SystemColors { + return { + colorPrimary: antdTokens.colorPrimary, + colorError: antdTokens.colorError, + colorWarning: antdTokens.colorWarning, + colorSuccess: antdTokens.colorSuccess, + colorInfo: antdTokens.colorInfo, + }; + } + + private static getSupersetTheme( + seed: Partial, + isDark = false, + ): SupersetTheme { + const antdConfig = Theme.getAntdConfig(seed, isDark); + const antdTokens = Theme.getFilteredAntdTheme(antdConfig); + const systemColors = Theme.getSystemColors(antdTokens); + + const theme: SupersetTheme = { + colors: Theme.getColors(systemColors, isDark), + ...Theme.defaultTokens, + // Bring allowed tokens from antd + ...antdTokens, + }; + return theme; + } + + private static getFilteredAntdTheme( + antdConfig: AntdThemeConfig, + ): SharedAntdTokens { + const theme = Theme.getAntdTokens(antdConfig); + + return Object.fromEntries( + allowedAntdTokens.map(key => [key, theme[key]]), // Map keys to their values from the theme + ) as SharedAntdTokens; + } + + private static getAntdConfig( + seed: Partial, + isDark: boolean, + ): AntdThemeConfig { + const algorithm = isDark + ? antdThemeImport.darkAlgorithm + : antdThemeImport.defaultAlgorithm; + + return { + token: seed, + algorithm, + }; + } + + mergeTheme(partialTheme: Partial): void { + // const mergedTheme = merge({}, this.theme, partialTheme); + // const isDark = tinycolor(mergedTheme.colorBgBase).isDark(); + // const antdConfig = Theme.getAntdConfig(systemColors, isDark); + // this.updateTheme(mergedTheme, antdConfig, isDark); + } + + private updateTheme(theme: SupersetTheme, antdConfig: AntdThemeConfig): void { + this.theme = theme; + this.antdConfig = antdConfig; + this.updateProviders( + this.theme, + this.antdConfig, + createCache({ key: 'superset' }), + ); + } + + public getFontSize(size?: string): string { + const sizeMap: Record = { + xs: 'fontSizeXS', + s: 'fontSizeSM', + m: 'fontSize', + l: 'fontSizeLG', + xl: 'fontSizeXL', + xxl: 'fontSizeXXL', + }; + return this.theme[sizeMap[size || 'm']] || this.theme.fontSize; + } + + setThemeFromSeed(seed: Partial, isDark: boolean): void { + const augmentedSeed = Theme.augmentSeedWithDefaults(seed); + const theme = Theme.getSupersetTheme(augmentedSeed, isDark); + const antdConfig = Theme.getAntdConfig(augmentedSeed, isDark); + this.updateTheme(theme, antdConfig); + } + + getColorVariants(color: string): ColorVariants { + const firstLetterCapped = color.charAt(0).toUpperCase() + color.slice(1); + if (color === 'default' || color === 'grayscale') { + const isDark = this.isThemeDark(); + + const flipBrightness = (baseColor: string): string => { + if (!isDark) return baseColor; + const { r, g, b } = tinycolor(baseColor).toRgb(); + const invertedColor = tinycolor({ r: 255 - r, g: 255 - g, b: 255 - b }); + return invertedColor.toHexString(); + }; + + return { + active: flipBrightness('#222'), + textActive: flipBrightness('#444'), + text: flipBrightness('#555'), + textHover: flipBrightness('#666'), + hover: flipBrightness('#888'), + borderHover: flipBrightness('#AAA'), + border: flipBrightness('#CCC'), + bgHover: flipBrightness('#DDD'), + bg: flipBrightness('#F4F4F4'), + }; + } + + return { + active: this.theme[`color${firstLetterCapped}Active`], + textActive: this.theme[`color${firstLetterCapped}TextActive`], + text: this.theme[`color${firstLetterCapped}Text`], + textHover: this.theme[`color${firstLetterCapped}TextHover`], + hover: this.theme[`color${firstLetterCapped}Hover`], + borderHover: this.theme[`color${firstLetterCapped}BorderHover`], + border: this.theme[`color${firstLetterCapped}Border`], + bgHover: this.theme[`color${firstLetterCapped}BgHover`], + bg: this.theme[`color${firstLetterCapped}Bg`], + }; + } + + private static getAntdTokens(antdConfig: AntdThemeConfig): AntdTokens { + return antdThemeImport.getDesignToken(antdConfig); + } + + private isThemeDark(): boolean { + return tinycolor(this.theme.colorBgContainer).isDark(); + } + + setThemeFromAntdConfig(antdConfig: AntdThemeConfig): void { + this.antdConfig = antdConfig; + const tokens = Theme.getFilteredAntdTheme(antdConfig); + const systemColors = Theme.getSystemColors(tokens); + const isDark = this.isThemeDark(); + + this.theme = { + colors: Theme.getColors(systemColors, isDark), + ...Theme.defaultTokens, + ...tokens, + }; + this.updateProviders( + this.theme, + this.antdConfig, + createCache({ key: 'superset' }), + ); + } + + private updateProviders( + theme: SupersetTheme, + antdConfig: AntdThemeConfig, + emotionCache: any, + ): void {} + + SupersetThemeProvider({ children }: { children: React.ReactNode }) { + if (!this.theme || !this.antdConfig) { + throw new Error('Theme is not initialized.'); + } + + // eslint-disable-next-line react-hooks/rules-of-hooks + const [themeState, setThemeState] = React.useState({ + theme: this.theme, + antdConfig: this.antdConfig, + emotionCache: createCache({ key: 'superset' }), + }); + + this.updateProviders = (theme, antdConfig, emotionCache) => { + setThemeState({ theme, antdConfig, emotionCache }); + }; + return ( + + + + {children} + + + + ); + } +} diff --git a/superset-frontend/packages/superset-ui-core/src/theme/index.tsx b/superset-frontend/packages/superset-ui-core/src/theme/index.tsx new file mode 100644 index 0000000000000..016c20606135d --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/src/theme/index.tsx @@ -0,0 +1,71 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import emotionStyled from '@emotion/styled'; +import { useTheme as useThemeBasic } from '@emotion/react'; +// import { theme as antdThemeImport } from 'antd-v5'; +import { Theme } from './Theme'; +import type { SupersetTheme } from './Theme'; + +export { + css, + keyframes, + jsx, + ThemeProvider, + CacheProvider as EmotionCacheProvider, + withTheme, +} from '@emotion/react'; +export { default as createEmotionCache } from '@emotion/cache'; + +declare module '@emotion/react' { + // eslint-disable-next-line @typescript-eslint/no-empty-interface + export interface Theme extends SupersetTheme {} +} + +export function useTheme() { + const theme = useThemeBasic(); + // in the case there is no theme, useTheme returns an empty object + if (Object.keys(theme).length === 0 && theme.constructor === Object) { + throw new Error( + 'useTheme() could not find a ThemeContext. The component is likely missing from the app.', + ); + } + return theme; +} + +const styled = emotionStyled; + +// launching in in dark mode for now while iterating +const themeObject = Theme.fromSeed({}, true); +/* +const themeObject = Theme.fromSeed({ + token: { + colorPrimary: '#20a7c9', + colorError: '#e04355', + colorWarning: '#fcc700', + colorSuccess: '#5ac189', + colorInfo: '#66bcfe', + }, + algorithm: antdThemeImport.defaultAlgorithm, +}); + */ + +const { theme } = themeObject; +const supersetTheme = theme; + +export { Theme, SupersetTheme, themeObject, styled, theme, supersetTheme }; diff --git a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts index 34e8d51f27fd7..bc0cec8437700 100644 --- a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts +++ b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts @@ -62,6 +62,7 @@ export enum FeatureFlag { SlackEnableAvatars = 'SLACK_ENABLE_AVATARS', EnableDashboardScreenshotEndpoints = 'ENABLE_DASHBOARD_SCREENSHOT_ENDPOINTS', EnableDashboardDownloadWebDriverScreenshot = 'ENABLE_DASHBOARD_DOWNLOAD_WEBDRIVER_SCREENSHOT', + DarkThemeSwitch = 'DARK_THEME_SWITCH', } export type ScheduleQueriesProps = { diff --git a/superset-frontend/packages/superset-ui-core/test/chart/components/FallbackComponent.test.tsx b/superset-frontend/packages/superset-ui-core/test/chart/components/FallbackComponent.test.tsx index 2a52c62e5e8ec..dcbaeee56361a 100644 --- a/superset-frontend/packages/superset-ui-core/test/chart/components/FallbackComponent.test.tsx +++ b/superset-frontend/packages/superset-ui-core/test/chart/components/FallbackComponent.test.tsx @@ -20,7 +20,7 @@ import { render } from '@testing-library/react'; import '@testing-library/jest-dom'; import { FallbackProps } from 'react-error-boundary'; -import { ThemeProvider, supersetTheme } from '../../../src/style'; +import { ThemeProvider, supersetTheme } from '../../../src/theme'; import FallbackComponent from '../../../src/chart/components/FallbackComponent'; diff --git a/superset-frontend/packages/superset-ui-core/test/chart/components/NoResultsComponent.test.tsx b/superset-frontend/packages/superset-ui-core/test/chart/components/NoResultsComponent.test.tsx index f736d44b99578..5a38c8c98e394 100644 --- a/superset-frontend/packages/superset-ui-core/test/chart/components/NoResultsComponent.test.tsx +++ b/superset-frontend/packages/superset-ui-core/test/chart/components/NoResultsComponent.test.tsx @@ -19,7 +19,7 @@ import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; -import { ThemeProvider, supersetTheme } from '../../../src/style'; +import { ThemeProvider, supersetTheme } from '../../../src/theme'; import NoResultsComponent from '../../../src/chart/components/NoResultsComponent'; const renderNoResultsComponent = () => diff --git a/superset-frontend/packages/superset-ui-core/test/style/index.test.tsx b/superset-frontend/packages/superset-ui-core/test/style/index.test.tsx deleted file mode 100644 index 352ea4b6a01e9..0000000000000 --- a/superset-frontend/packages/superset-ui-core/test/style/index.test.tsx +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { - styled, - supersetTheme, - SupersetThemeProps, - useTheme, - ThemeProvider, - EmotionCacheProvider, - emotionCache, -} from '@superset-ui/core'; -import { render } from '@testing-library/react'; - -describe('@superset-ui/style package', () => { - it('exports a theme', () => { - expect(typeof supersetTheme).toBe('object'); - }); - - it('exports styled component templater', () => { - expect(typeof styled.div).toBe('function'); - }); - - it('exports SupersetThemeProps', () => { - const props: SupersetThemeProps = { - theme: supersetTheme, - }; - expect(typeof props).toBe('object'); - }); - - describe('useTheme()', () => { - it('returns the theme', () => { - function ThemeUser() { - expect(useTheme()).toStrictEqual(supersetTheme); - return
test
; - } - render(, { - wrapper: ({ children }) => ( - - {children} - - ), - }); - }); - - it('throws when a theme is not present', () => { - function ThemeUser() { - expect(useTheme).toThrow(/could not find a ThemeContext/); - return
test
; - } - render(, { - wrapper: ({ children }) =>
{children}
, - }); - }); - }); -}); diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-plugin-chart-map-box/data.ts b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-plugin-chart-map-box/data.ts index 19a3c4c5a592f..b138443942c03 100644 --- a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-plugin-chart-map-box/data.ts +++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-plugin-chart-map-box/data.ts @@ -5539,5 +5539,5 @@ export const generateData = (theme: SupersetTheme) => ({ ], renderWhileDragging: true, tooltip: null, - color: theme.colors.primary.base, + color: theme.colorPrimary, }); diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-preset-chart-deckgl/Path/payload.js b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-preset-chart-deckgl/Path/payload.js index 5a36d7e32c337..f92ad3210a5f1 100644 --- a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-preset-chart-deckgl/Path/payload.js +++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-preset-chart-deckgl/Path/payload.js @@ -81,7 +81,7 @@ export const payload = theme => ({ data: { features: [ { - color: theme.colors.primary.base, + color: theme.colorPrimary, path: [ [-122.3535851, 37.9360513], [-122.3179784, 37.9249513], @@ -108,10 +108,10 @@ export const payload = theme => ({ [-122.3876274, 37.5993171], ], __timestamp: null, - extraProps: { color: theme.colors.primary.base }, + extraProps: { color: theme.colorPrimary }, }, { - color: theme.colors.warning.base, + color: theme.colorWarning, path: [ [-122.353165, 37.936887], [-122.317269, 37.925655], @@ -133,10 +133,10 @@ export const payload = theme => ({ [-121.9772135, 37.5567286], ], __timestamp: null, - extraProps: { color: theme.colors.warning.base }, + extraProps: { color: theme.colorWarning }, }, { - color: theme.colors.error.base, + color: theme.colorError, path: [ [-121.945154, 38.018914], [-122.024597, 38.003275], @@ -166,10 +166,10 @@ export const payload = theme => ({ [-122.38666, 37.599787], ], __timestamp: null, - extraProps: { color: theme.colors.error.base }, + extraProps: { color: theme.colorError }, }, { - color: theme.colors.success.base, + color: theme.colorSuccess, path: [ [-121.900367, 37.701695], [-121.928099, 37.699759], @@ -191,10 +191,10 @@ export const payload = theme => ({ [-122.469081, 37.706121], ], __timestamp: null, - extraProps: { color: theme.colors.success.base }, + extraProps: { color: theme.colorSuccess }, }, { - color: theme.colors.warning.base, + color: theme.colorWarning, path: [ [-121.9764, 37.557355], [-122.017867, 37.591208], @@ -217,7 +217,7 @@ export const payload = theme => ({ [-122.4683093, 37.705461], ], __timestamp: null, - extraProps: { color: theme.colors.warning.base }, + extraProps: { color: theme.colorWarning }, }, ], mapboxApiKey: diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-style/Theme.stories.tsx b/superset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-style/Theme.stories.tsx deleted file mode 100644 index b46c9dfb81297..0000000000000 --- a/superset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-style/Theme.stories.tsx +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { supersetTheme } from '@superset-ui/core'; - -export default { - title: 'Core Packages/@superset-ui-style', -}; - -export const ThemeColors = () => { - const { colors } = supersetTheme; - - // Define tones to be displayed in columns - const tones = [ - 'dark2', - 'dark1', - 'base', - 'light1', - 'light2', - 'light3', - 'light4', - 'light5', - ]; - const colorTypes = [ - 'primary', - 'secondary', - 'grayscale', - 'error', - 'warning', - 'alert', - 'success', - 'info', - ]; - return ( -
-

Theme Colors

- - - - - {tones.map(tone => ( - - ))} - - - - {colorTypes.map(category => ( - - - {tones.map(tone => { - const color = colors[category][tone]; - return ( - - ); - })} - - ))} - -
- Category - - {tone} -
- {category} - - {color ? {color} : '-'} -
-

- text.label: {colors.text.label} -

-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod - tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim - veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea - commodo consequat. -
-

- text.help: {colors.text.help} -

-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod - tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim - veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea - commodo consequat. -
-

The supersetTheme object

- -
{JSON.stringify(supersetTheme, null, 2)}
-
-
- ); -}; diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-theme/Theme.stories.tsx b/superset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-theme/Theme.stories.tsx new file mode 100644 index 0000000000000..503407ce66658 --- /dev/null +++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-theme/Theme.stories.tsx @@ -0,0 +1,176 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + * OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { supersetTheme, themeObject } from '@superset-ui/core'; + +const colorTypes = [ + 'primary', + 'error', + 'warning', + 'success', + 'info', + 'grayscale', +]; + +const AntDFunctionalColors = ({ antdTheme }) => { + const { antd } = supersetTheme; + + // Define color types and variants dynamically + const variants = [ + 'active', + 'textActive', + 'text', + 'textHover', + 'hover', + 'borderHover', + 'border', + 'bgHover', + 'bg', + ]; + + const { colors } = supersetTheme; + return ( + + + + + {variants.map(variant => ( + + ))} + + + + {colorTypes.map(type => { + const typeKey = `color${type}`; + return ( + + + {variants.map(variant => { + const color = themeObject.getColorVariants(type)[variant]; + return ( + + ); + })} + + ); + })} + +
Type + {variant} +
+ {type} + + {color ? {color} : '-'} +
+ ); +}; + +export const ThemeColors = () => { + const { colors } = supersetTheme; + + // Define tones to be displayed in columns + const tones = [ + 'dark5', + 'dark4', + 'dark3', + 'dark1', + 'base', + 'light1', + 'light2', + 'light3', + 'light4', + 'light5', + ]; + return ( +
+

Theme Colors

+

Legacy Theme Colors

+ + + + + {tones.map(tone => ( + + ))} + + + + {colorTypes.map(category => ( + + + {tones.map(tone => { + const color = colors[category][tone]; + return ( + + ); + })} + + ))} + +
+ Category + + {tone} +
+ {category} + + {color ? {color} : '-'} +
+

Ant Design Theme Colors

+

Functional Colors

+ +

The supersetTheme object

+
+        {JSON.stringify(supersetTheme, null, 2)}
+      
+
+ ); +}; +/* + * */ +export default { + title: 'Core Packages/@superset-ui-theme', +}; + +export const Default = () => ; diff --git a/superset-frontend/plugins/legacy-plugin-chart-calendar/src/ReactCalendar.jsx b/superset-frontend/plugins/legacy-plugin-chart-calendar/src/ReactCalendar.jsx index 46cb1de852ada..c78fe7e56af2b 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-calendar/src/ReactCalendar.jsx +++ b/superset-frontend/plugins/legacy-plugin-chart-calendar/src/ReactCalendar.jsx @@ -31,19 +31,19 @@ const Calendar = ({ className, ...otherProps }) => { styles={css` .d3-tip { line-height: 1; - padding: ${theme.gridUnit * 3}px; + padding: ${theme.sizeUnit * 3}px; background: ${theme.colors.grayscale.dark2}; color: ${theme.colors.grayscale.light5}; border-radius: 4px; pointer-events: none; z-index: 1000; - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; } /* Creates a small triangle extender for the tooltip */ .d3-tip:after { box-sizing: border-box; display: inline; - font-size: ${theme.typography.sizes.xs}; + font-size: ${theme.fontSizeXS}; width: 100%; line-height: 1; color: ${theme.colors.grayscale.dark2}; @@ -53,7 +53,7 @@ const Calendar = ({ className, ...otherProps }) => { /* Northward tooltips */ .d3-tip.n:after { content: '\\25BC'; - margin: -${theme.gridUnit}px 0 0 0; + margin: -${theme.sizeUnit}px 0 0 0; top: 100%; left: 0; text-align: center; @@ -61,22 +61,22 @@ const Calendar = ({ className, ...otherProps }) => { /* Eastward tooltips */ .d3-tip.e:after { content: '\\25C0'; - margin: -${theme.gridUnit}px 0 0 0; + margin: -${theme.sizeUnit}px 0 0 0; top: 50%; - left: -${theme.gridUnit * 2}px; + left: -${theme.sizeUnit * 2}px; } /* Southward tooltips */ .d3-tip.s:after { content: '\\25B2'; margin: 0; - top: -${theme.gridUnit * 2}px; + top: -${theme.sizeUnit * 2}px; left: 0; text-align: center; } /* Westward tooltips */ .d3-tip.w:after { content: '\\25B6'; - margin: -${theme.gridUnit}px 0 0 0px; + margin: -${theme.sizeUnit}px 0 0 0px; top: 50%; left: 100%; } @@ -99,19 +99,19 @@ Calendar.propTypes = { export default styled(Calendar)` ${({ theme }) => ` .superset-legacy-chart-calendar { - padding: ${theme.gridUnit * 3}px; + padding: ${theme.sizeUnit * 3}px; position: static !important; overflow: auto !important; } .superset-legacy-chart-calendar .ch-tooltip { - margin-left: ${theme.gridUnit * 5}px; - margin-top: ${theme.gridUnit}px; + margin-left: ${theme.sizeUnit * 5}px; + margin-top: ${theme.sizeUnit}px; } .superset-legacy-chart-calendar .d3-tip { line-height: 1; - padding: ${theme.gridUnit * 3}px; + padding: ${theme.sizeUnit * 3}px; background: ${theme.colors.grayscale.dark2}; color: ${theme.colors.grayscale.light5}; border-radius: ${theme.borderRadius}px; @@ -125,7 +125,7 @@ export default styled(Calendar)` .cal-heatmap-container .graph-label { fill: ${theme.colors.grayscale.base}; - font-size: ${theme.typography.sizes.xs}px; + font-size: ${theme.fontSizeXS}px; } .cal-heatmap-container .graph, @@ -143,7 +143,7 @@ export default styled(Calendar)` } .cal-heatmap-container .subdomain-text { - font-size: ${theme.typography.sizes.xs}px; + font-size: ${theme.fontSizeXS}px; pointer-events: none; } @@ -172,8 +172,8 @@ export default styled(Calendar)` } .cal-heatmap-container .q4 { - background-color: ${theme.colors.success.base}; - fill: ${theme.colors.success.base}; + background-color: ${theme.colorSuccess}; + fill: ${theme.colorSuccess}; } .cal-heatmap-container .q5 { @@ -182,21 +182,21 @@ export default styled(Calendar)` } .cal-heatmap-container rect.highlight { - stroke: ${theme.colors.grayscale.dark1}; + stroke: ${theme.colorText}; stroke-width: 1; } .cal-heatmap-container text.highlight { - fill: ${theme.colors.grayscale.dark1}; + fill: ${theme.colorText}; } .cal-heatmap-container rect.highlight-now { - stroke: ${theme.colors.error.base}; + stroke: ${theme.colorError}; } .cal-heatmap-container text.highlight-now { - fill: ${theme.colors.error.base}; - font-weight: ${theme.typography.weights.bold}; + fill: ${theme.colorError}; + font-weight: ${theme.fontWeightStrong}; } .cal-heatmap-container .domain-background { @@ -205,10 +205,10 @@ export default styled(Calendar)` } .ch-tooltip { - padding: ${theme.gridUnit * 2}px; - background: ${theme.colors.grayscale.dark1}; + padding: ${theme.sizeUnit * 2}px; + background: ${theme.colorText}; color: ${theme.colors.grayscale.light1}; - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; line-height: 1.4; width: 140px; position: absolute; @@ -229,11 +229,11 @@ export default styled(Calendar)` content: ''; padding: 0; display: block; - bottom: -${theme.gridUnit}px; + bottom: -${theme.sizeUnit}px; left: 50%; - margin-left: -${theme.gridUnit}px; - border-width: ${theme.gridUnit}px ${theme.gridUnit}px 0; - border-top-color: ${theme.colors.grayscale.dark1}; + margin-left: -${theme.sizeUnit}px; + border-width: ${theme.sizeUnit}px ${theme.sizeUnit}px 0; + border-top-color: ${theme.colorText}; } `} `; diff --git a/superset-frontend/plugins/legacy-plugin-chart-chord/src/ReactChord.jsx b/superset-frontend/plugins/legacy-plugin-chart-chord/src/ReactChord.jsx index 7de87414cc2df..d413a79537000 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-chord/src/ReactChord.jsx +++ b/superset-frontend/plugins/legacy-plugin-chart-chord/src/ReactChord.jsx @@ -44,14 +44,14 @@ export default styled(Chord)` pointer-events: all; } .superset-legacy-chart-chord svg .group path { - fill-opacity: ${theme.opacity.mediumHeavy}; + fill-opacity: 60%; } .superset-legacy-chart-chord svg path.chord { - stroke: ${theme.colors.grayscale.dark2}; + stroke: ${theme.colorText}; stroke-width: 0.25px; } .superset-legacy-chart-chord svg #circle:hover path.fade { - opacity: ${theme.opacity.light}; + opacity: 10%; } `} `; diff --git a/superset-frontend/plugins/legacy-plugin-chart-country-map/src/ReactCountryMap.jsx b/superset-frontend/plugins/legacy-plugin-chart-country-map/src/ReactCountryMap.jsx index ea6a936b5aad9..b857b36040852 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-country-map/src/ReactCountryMap.jsx +++ b/superset-frontend/plugins/legacy-plugin-chart-country-map/src/ReactCountryMap.jsx @@ -52,19 +52,19 @@ export default styled(CountryMap)` } .superset-legacy-chart-country-map .text-layer { - color: ${theme.colors.grayscale.dark1}; + color: ${theme.colorText}; text-anchor: middle; pointer-events: none; } .superset-legacy-chart-country-map text.result-text { - font-weight: ${theme.typography.weights.light}; - font-size: ${theme.typography.sizes.xl}px; + font-weight: ${theme.fontWeightLight}; + font-size: ${theme.fontSizeXL}px; } .superset-legacy-chart-country-map text.big-text { - font-weight: ${theme.typography.weights.bold}; - font-size: ${theme.typography.sizes.l}px; + font-weight: ${theme.fontWeightStrong}; + font-size: ${theme.fontSizeLG}px; } .superset-legacy-chart-country-map path.region { diff --git a/superset-frontend/plugins/legacy-plugin-chart-horizon/src/HorizonChart.jsx b/superset-frontend/plugins/legacy-plugin-chart-horizon/src/HorizonChart.jsx index dc72cb664add9..05b4b6e9aac41 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-horizon/src/HorizonChart.jsx +++ b/superset-frontend/plugins/legacy-plugin-chart-horizon/src/HorizonChart.jsx @@ -73,8 +73,8 @@ const StyledDiv = styled.div` .superset-legacy-chart-horizon .horizon-row span.title { position: absolute; - color: ${theme.colors.grayscale.dark1}; - font-size: ${theme.typography.sizes.s}px; + color: ${theme.colorText}; + font-size: ${theme.fontSizeSM}px; margin: 0; } `} diff --git a/superset-frontend/plugins/legacy-plugin-chart-paired-t-test/src/PairedTTest.jsx b/superset-frontend/plugins/legacy-plugin-chart-paired-t-test/src/PairedTTest.jsx index 27b2f7239ea61..f15a85f4476de 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-paired-t-test/src/PairedTTest.jsx +++ b/superset-frontend/plugins/legacy-plugin-chart-paired-t-test/src/PairedTTest.jsx @@ -46,8 +46,8 @@ const StyledDiv = styled.div` } .paired-ttest-table .scrollbar-content { - padding-left: ${theme.gridUnit}px; - padding-right: ${theme.gridUnit}px; + padding-left: ${theme.sizeUnit}px; + padding-right: ${theme.sizeUnit}px; margin-bottom: 0; } @@ -56,7 +56,7 @@ const StyledDiv = styled.div` } .paired-ttest-table h1 { - margin-left: ${theme.gridUnit}px; + margin-left: ${theme.sizeUnit}px; } .reactable-data tr { @@ -74,19 +74,19 @@ const StyledDiv = styled.div` } .reactable-data tr .false { - color: ${theme.colors.error.base}; + color: ${theme.colorError}; } .reactable-data tr .true { - color: ${theme.colors.success.base}; + color: ${theme.colorSuccess}; } .reactable-data tr .control { - color: ${theme.colors.primary.base}; + color: ${theme.colorPrimary}; } .reactable-data tr .invalid { - color: ${theme.colors.warning.base}; + color: ${theme.colorWarning}; } .reactable-data .control td { @@ -104,13 +104,13 @@ const StyledDiv = styled.div` .reactable-header-sort-asc:after { content: '\\25bc'; position: absolute; - right: ${theme.gridUnit * 3}px; + right: ${theme.sizeUnit * 3}px; } .reactable-header-sort-desc:after { content: '\\25b2'; position: absolute; - right: ${theme.gridUnit * 3}px; + right: ${theme.sizeUnit * 3}px; } `} `; diff --git a/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/src/ReactParallelCoordinates.jsx b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/src/ReactParallelCoordinates.jsx index e9e03af1d3b7e..740d4043df69f 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/src/ReactParallelCoordinates.jsx +++ b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/src/ReactParallelCoordinates.jsx @@ -46,7 +46,7 @@ export default styled(ParallelCoordinates)` } .parcoords svg, .parcoords canvas { - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; position: absolute; } .parcoords > canvas { @@ -55,7 +55,7 @@ export default styled(ParallelCoordinates)` .parcoords text.label { font: 100%; - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; cursor: drag; } .parcoords rect.background { @@ -74,7 +74,7 @@ export default styled(ParallelCoordinates)` .parcoords .axis line, .parcoords .axis path { fill: none; - stroke: ${theme.colors.grayscale.dark1}; + stroke: ${theme.colorText}; shape-rendering: crispEdges; } .parcoords canvas { @@ -84,7 +84,7 @@ export default styled(ParallelCoordinates)` -o-transition: opacity 0.3s; } .parcoords canvas.faded { - opacity: ${theme.opacity.mediumLight}; + opacity: 35%; } .parcoords { -webkit-touch-callout: none; @@ -100,7 +100,7 @@ export default styled(ParallelCoordinates)` .parcoords .row, .parcoords .header { clear: left; - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; line-height: 18px; height: 18px; margin: 0px; @@ -109,7 +109,7 @@ export default styled(ParallelCoordinates)` background: ${addAlpha(theme.colors.grayscale.dark2, 0.05)}; } .parcoords .header { - font-weight: ${theme.typography.weights.bold}; + font-weight: ${theme.fontWeightStrong}; } .parcoords .cell { float: left; diff --git a/superset-frontend/plugins/legacy-plugin-chart-partition/src/ReactPartition.jsx b/superset-frontend/plugins/legacy-plugin-chart-partition/src/ReactPartition.jsx index bfb1340fd70a1..521ad32e7c2b4 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-partition/src/ReactPartition.jsx +++ b/superset-frontend/plugins/legacy-plugin-chart-partition/src/ReactPartition.jsx @@ -36,13 +36,13 @@ export default styled(Partition)` .superset-legacy-chart-partition .chart { display: block; margin: auto; - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; } .superset-legacy-chart-partition rect { stroke: ${theme.colors.grayscale.light2}; fill: ${theme.colors.grayscale.light1}; - fill-opacity: ${theme.opacity.heavy}; + fill-opacity: 80%; transition: fill-opacity 180ms linear; cursor: pointer; } @@ -52,8 +52,8 @@ export default styled(Partition)` } .superset-legacy-chart-partition g text { - font-weight: ${theme.typography.weights.bold}; - fill: ${theme.colors.grayscale.dark1}; + font-weight: ${theme.fontWeightStrong}; + fill: ${theme.colorText}; } .superset-legacy-chart-partition g:hover text { @@ -65,15 +65,15 @@ export default styled(Partition)` top: 0; left: 0; opacity: 0; - padding: ${theme.gridUnit}px; + padding: ${theme.sizeUnit}px; pointer-events: none; background-color: ${theme.colors.grayscale.dark2}; - border-radius: ${theme.gridUnit}px; + border-radius: ${theme.sizeUnit}px; } .partition-tooltip td { - padding-left: ${theme.gridUnit}px; - font-size: ${theme.typography.sizes.s}px; + padding-left: ${theme.sizeUnit}px; + font-size: ${theme.fontSizeSM}px; color: ${theme.colors.grayscale.light5}; } `} diff --git a/superset-frontend/plugins/legacy-plugin-chart-rose/src/ReactRose.jsx b/superset-frontend/plugins/legacy-plugin-chart-rose/src/ReactRose.jsx index efd9b59aef6ab..b7a2c0c800b5f 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-rose/src/ReactRose.jsx +++ b/superset-frontend/plugins/legacy-plugin-chart-rose/src/ReactRose.jsx @@ -28,13 +28,13 @@ const Rose = ({ className, ...otherProps }) => ( styles={theme => css` .tooltip { line-height: 1; - padding: ${theme.gridUnit * 3}px; + padding: ${theme.sizeUnit * 3}px; background: ${theme.colors.grayscale.dark2}; color: ${theme.colors.grayscale.light5}; border-radius: 4px; pointer-events: none; z-index: 1000; - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; } `} /> @@ -53,9 +53,8 @@ export default styled(Rose)` } .superset-legacy-chart-rose text { - font-weight: ${theme.typography.weights.normal}; - font-size: ${theme.typography.sizes.s}px; - font-family: ${theme.typography.families.sansSerif}; + font-size: ${theme.fontSizeSM}px; + font-family: ${theme.fontFamily}; pointer-events: none; } diff --git a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js index 03ea4ea9c78ba..092aa007f3032 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js +++ b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js @@ -265,7 +265,7 @@ function WorldMap(element, props) { countryFeature => !filterState.selectedValues.includes(countryFeature.id), ) - .style('fill-opacity', theme.opacity.mediumLight); + .style('fill-opacity', 0.35); // hack to ensure that the clicked country's color is preserved // sometimes the fill color would get default grey value after applying cross filter diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/components/Legend.tsx b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/components/Legend.tsx index ab8ae78b73efb..1bd92b53db220 100644 --- a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/components/Legend.tsx +++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/components/Legend.tsx @@ -24,12 +24,12 @@ import { formatNumber, styled } from '@superset-ui/core'; const StyledLegend = styled.div` ${({ theme }) => ` - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; position: absolute; background: ${theme.colors.grayscale.light5}; - box-shadow: 0 0 ${theme.gridUnit}px ${theme.colors.grayscale.light2}; - margin: ${theme.gridUnit * 6}px; - padding: ${theme.gridUnit * 3}px ${theme.gridUnit * 5}px; + box-shadow: 0 0 ${theme.sizeUnit}px ${theme.colors.grayscale.light2}; + margin: ${theme.sizeUnit * 6}px; + padding: ${theme.sizeUnit * 3}px ${theme.sizeUnit * 5}px; outline: none; overflow-y: scroll; max-height: 200px; @@ -43,10 +43,10 @@ const StyledLegend = styled.div` display: flex; color: ${theme.colors.grayscale.base}; text-decoration: none; - padding: ${theme.gridUnit}px 0; + padding: ${theme.sizeUnit}px 0; & span { - margin-right: ${theme.gridUnit}px; + margin-right: ${theme.sizeUnit}px; } } } diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/components/Tooltip.tsx b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/components/Tooltip.tsx index 0e9801c52f354..7b58d087458c5 100644 --- a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/components/Tooltip.tsx +++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/components/Tooltip.tsx @@ -36,12 +36,12 @@ const StyledDiv = styled.div<{ top: number; left: number }>` position: absolute; top: ${top}px; left: ${left}px; - padding: ${theme.gridUnit * 2}px; - margin: ${theme.gridUnit * 2}px; + padding: ${theme.sizeUnit * 2}px; + margin: ${theme.sizeUnit * 2}px; background: ${theme.colors.grayscale.dark2}; color: ${theme.colors.grayscale.light5}; maxWidth: 300px; - fontSize: ${theme.typography.sizes.s}px; + fontSize: ${theme.fontSizeSM}px; zIndex: 9; pointerEvents: none; `} diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/ReactNVD3.jsx b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/ReactNVD3.jsx index dfb2124ef035b..21397be6d5b49 100644 --- a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/ReactNVD3.jsx +++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/ReactNVD3.jsx @@ -49,23 +49,23 @@ export default styled(NVD3)` svg { &.nvd3-svg { width: auto; - font-size: ${({ theme }) => theme.typography.sizes.m}; + font-size: ${({ theme }) => theme.fontSize}; } } } .superset-legacy-chart-nvd3 { nv-x text { - font-size: ${({ theme }) => theme.typography.sizes.m}; + font-size: ${({ theme }) => theme.fontSize}; } g.superset path { stroke-dasharray: 5, 5; } .nvtooltip tr.highlight td { - font-weight: ${({ theme }) => theme.typography.weights.bold}; - font-size: ${({ theme }) => theme.typography.sizes.m}px !important; + font-weight: ${({ theme }) => theme.fontWeightStrong}; + font-size: ${({ theme }) => theme.fontSize}px !important; } text.nv-axislabel { - font-size: ${({ theme }) => theme.typography.sizes.m} !important; + font-size: ${({ theme }) => theme.fontSize} !important; } g.solid path, line.solid { @@ -134,22 +134,22 @@ export default styled(NVD3)` stroke-dasharray: 5, 5, 1, 5; } .nv-noData.body { - font-size: ${({ theme }) => theme.typography.sizes.m}; - font-weight: ${({ theme }) => theme.typography.weights.normal}; + font-size: ${({ theme }) => theme.fontSize}; + font-weight: ${({ theme }) => theme.fontWeightNormal}; } } .superset-legacy-chart-nvd3-tr-highlight { border-top: 1px solid; border-bottom: 1px solid; - font-weight: ${({ theme }) => theme.typography.weights.bold}; + font-weight: ${({ theme }) => theme.fontWeightStrong}; } .superset-legacy-chart-nvd3-tr-total { - font-weight: ${({ theme }) => theme.typography.weights.bold}; + font-weight: ${({ theme }) => theme.fontWeightStrong}; } .nvtooltip { .tooltip-header { white-space: nowrap; - font-weight: ${({ theme }) => theme.typography.weights.bold}; + font-weight: ${({ theme }) => theme.fontWeightStrong}; } tbody tr:not(.tooltip-header) td:nth-of-type(2) { word-break: break-word; @@ -161,12 +161,12 @@ export default styled(NVD3)` border-radius: 2px; background-color: ${({ theme }) => theme.colors.grayscale.base}; fill-opacity: 0.6; - margin: ${({ theme }) => theme.gridUnit * 2}px; - padding: ${({ theme }) => theme.gridUnit * 2}px; + margin: ${({ theme }) => theme.sizeUnit * 2}px; + padding: ${({ theme }) => theme.sizeUnit * 2}px; color: ${({ theme }) => theme.colors.grayscale.light5}; &:after { content: '\\25BC'; - font-size: ${({ theme }) => theme.typography.sizes.m}; + font-size: ${({ theme }) => theme.fontSize}; color: ${({ theme }) => theme.colors.grayscale.base}; position: absolute; bottom: -14px; diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/PopKPI.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/PopKPI.tsx index a4736c89c2058..d4e5b2de0fe15 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/PopKPI.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/PopKPI.tsx @@ -47,10 +47,10 @@ const NumbersContainer = styled.div` const ComparisonValue = styled.div` ${({ theme, subheaderFontSize }) => ` - font-weight: ${theme.typography.weights.light}; + font-weight: ${theme.fontWeightLight}; display: flex; justify-content: center; - font-size: ${subheaderFontSize || 20}px; + font-size: ${String(subheaderFontSize) || 20}px; flex: 1 1 0px; `} `; @@ -59,9 +59,9 @@ const SymbolWrapper = styled.span` ${({ theme, backgroundColor, textColor }) => ` background-color: ${backgroundColor}; color: ${textColor}; - padding: ${theme.gridUnit}px ${theme.gridUnit * 2}px; - border-radius: ${theme.gridUnit * 2}px; - margin-right: ${theme.gridUnit}px; + padding: ${theme.sizeUnit}px ${theme.sizeUnit * 2}px; + border-radius: ${theme.sizeUnit * 2}px; + margin-right: ${theme.sizeUnit}px; `} `; @@ -122,9 +122,9 @@ export default function PopKPI(props: PopKPIProps) { }, [currentTimeRangeFilter, shift, startDateOffset, dashboardTimeRange]); const theme = useTheme(); - const flexGap = theme.gridUnit * 5; + const flexGap = theme.sizeUnit * 5; const wrapperDivStyles = css` - font-family: ${theme.typography.families.sansSerif}; + font-family: ${theme.fontFamily}; display: flex; justify-content: center; align-items: center; @@ -134,10 +134,10 @@ export default function PopKPI(props: PopKPIProps) { `; const bigValueContainerStyles = css` - font-size: ${headerFontSize || 60}px; - font-weight: ${theme.typography.weights.normal}; + font-size: ${String(headerFontSize) || 60}px; + font-weight: ${theme.fontWeightNormal}; text-align: center; - margin-bottom: ${theme.gridUnit * 4}px; + margin-bottom: ${theme.sizeUnit * 4}px; `; const getArrowIndicatorColor = () => { @@ -148,21 +148,21 @@ export default function PopKPI(props: PopKPIProps) { if (percentDifferenceNumber > 0) { // Positive difference return comparisonColorScheme === ColorSchemeEnum.Green - ? theme.colors.success.base - : theme.colors.error.base; + ? theme.colorSuccess + : theme.colorError; } // Negative difference return comparisonColorScheme === ColorSchemeEnum.Red - ? theme.colors.success.base - : theme.colors.error.base; + ? theme.colorSuccess + : theme.colorError; }; const arrowIndicatorStyle = css` color: ${getArrowIndicatorColor()}; - margin-left: ${theme.gridUnit}px; + margin-left: ${theme.sizeUnit}px; `; - const defaultBackgroundColor = theme.colors.grayscale.light4; + const defaultBackgroundColor = theme.colorBgContainer; const defaultTextColor = theme.colors.grayscale.base; const { backgroundColor, textColor } = useMemo(() => { let bgColor = defaultBackgroundColor; @@ -178,9 +178,7 @@ export default function PopKPI(props: PopKPIProps) { bgColor = useSuccess ? theme.colors.success.light2 : theme.colors.error.light2; - txtColor = useSuccess - ? theme.colors.success.base - : theme.colors.error.base; + txtColor = useSuccess ? theme.colorSuccess : theme.colorError; } return { diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/types.ts index e0ece4d8777ad..a2dbb1f29a227 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/types.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/types.ts @@ -18,17 +18,18 @@ */ import { QueryFormData, - supersetTheme, TimeseriesDataRecord, Metric, SimpleAdhocFilter, } from '@superset-ui/core'; +export type FontSizeOptions = 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'; + export interface PopKPIStylesProps { height: number; width: number; - headerFontSize: keyof typeof supersetTheme.typography.sizes; - subheaderFontSize: keyof typeof supersetTheme.typography.sizes; + headerFontSize: FontSizeOptions; + subheaderFontSize: FontSizeOptions; boldText: boolean; comparisonColorEnabled: boolean; } @@ -38,7 +39,7 @@ interface PopKPICustomizeProps { } export interface PopKPIComparisonValueStyleProps { - subheaderFontSize?: keyof typeof supersetTheme.typography.sizes; + subheaderFontSize?: FontSizeOptions; } export interface PopKPIComparisonSymbolStyleProps { diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberViz.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberViz.tsx index d7882ccdb6c15..0e8ad1a1ea9fe 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberViz.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberViz.tsx @@ -324,7 +324,7 @@ class BigNumberVis extends PureComponent { export default styled(BigNumberVis)` ${({ theme }) => ` - font-family: ${theme.typography.families.sansSerif}; + font-family: ${theme.fontFamily}; position: relative; display: flex; flex-direction: column; @@ -341,11 +341,11 @@ export default styled(BigNumberVis)` justify-content: center; align-items: flex-start; .alert { - font-size: ${theme.typography.sizes.s}; + font-size: ${theme.fontSizeSM}; margin: -0.5em 0 0.4em; line-height: 1; - padding: ${theme.gridUnit}px; - border-radius: ${theme.gridUnit}px; + padding: ${theme.sizeUnit}px; + border-radius: ${theme.sizeUnit}px; } } @@ -358,7 +358,7 @@ export default styled(BigNumberVis)` position: relative; line-height: 1em; white-space: nowrap; - margin-bottom:${theme.gridUnit * 2}px; + margin-bottom:${theme.sizeUnit * 2}px; span { position: absolute; bottom: 0; @@ -374,7 +374,7 @@ export default styled(BigNumberVis)` .kicker, .header-line, .subheader-line { - opacity: ${theme.opacity.mediumHeavy}; + opacity: 60%; } } `} diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/constants.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/constants.ts index 676b1f08d48c8..757b99342ed01 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/constants.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/constants.ts @@ -24,7 +24,7 @@ export const defaultGaugeSeriesOption = ( ): GaugeSeriesOption => ({ splitLine: { lineStyle: { - color: theme.colors.primary.base, + color: theme.colorPrimary, }, }, axisLine: { @@ -33,12 +33,12 @@ export const defaultGaugeSeriesOption = ( }, }, axisLabel: { - color: theme.colors.grayscale.dark1, + color: theme.colorText, }, axisTick: { lineStyle: { width: 2, - color: theme.colors.primary.base, + color: theme.colorPrimary, }, }, detail: { diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts index 853721b2926c2..68b9b2d807170 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts @@ -220,10 +220,10 @@ export default function transformProps( }); const minShowLabelAngle = (showLabelsThreshold || 0) * 3.6; const padding = { - top: theme.gridUnit * 3, - right: theme.gridUnit, - bottom: theme.gridUnit * 3, - left: theme.gridUnit, + top: theme.sizeUnit * 3, + right: theme.sizeUnit, + bottom: theme.sizeUnit * 3, + left: theme.sizeUnit, }; const containerWidth = width; const containerHeight = height; diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/transformProps.ts index 70755574fba75..5336f36ba880f 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Treemap/transformProps.ts @@ -238,7 +238,7 @@ export default function transformProps( show: false, }, itemStyle: { - color: theme.colors.primary.base, + color: theme.colorPrimary, }, }, ]; diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/transformProps.ts index ab21e7b37ccab..a1d410ab88203 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/transformProps.ts @@ -406,10 +406,10 @@ export default function transformProps( const echartOptions: EChartsOption = { grid: { ...defaultGrid, - top: theme.gridUnit * 7, - bottom: theme.gridUnit * 7, - left: theme.gridUnit * 5, - right: theme.gridUnit * 7, + top: theme.sizeUnit * 7, + bottom: theme.sizeUnit * 7, + left: theme.sizeUnit * 5, + right: theme.sizeUnit * 7, }, legend: { show: showLegend, @@ -421,7 +421,7 @@ export default function transformProps( type: 'category', name: xAxisLabel, nameTextStyle: { - padding: [theme.gridUnit * 4, 0, 0, 0], + padding: [theme.sizeUnit * 4, 0, 0, 0], }, nameLocation: 'middle', axisLabel, @@ -430,7 +430,7 @@ export default function transformProps( ...defaultYAxis, type: 'value', nameTextStyle: { - padding: [0, 0, theme.gridUnit * 5, 0], + padding: [0, 0, theme.sizeUnit * 5, 0], }, nameLocation: 'middle', name: yAxisLabel, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts b/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts index 0aa0ae988ee98..6c70b79016333 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts @@ -437,8 +437,8 @@ export function getLegendProps( selected: legendState, selector: ['all', 'inverse'], selectorLabel: { - fontFamily: theme.typography.families.sansSerif, - fontSize: theme.typography.sizes.s, + fontFamily: theme.fontFamily, + fontSize: theme.fontSizeSM, color: theme.colors.grayscale.base, borderColor: theme.colors.grayscale.base, }, diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts index 7054f6019ad30..37e8c00cded21 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts @@ -54,8 +54,8 @@ import { NULL_STRING } from '../../src/constants'; const expectedThemeProps = { selector: ['all', 'inverse'], selectorLabel: { - fontFamily: theme.typography.families.sansSerif, - fontSize: theme.typography.sizes.s, + fontFamily: theme.fontFamily, + fontSize: theme.fontSizeSM, color: theme.colors.grayscale.base, borderColor: theme.colors.grayscale.base, }, diff --git a/superset-frontend/plugins/plugin-chart-handlebars/src/Handlebars.tsx b/superset-frontend/plugins/plugin-chart-handlebars/src/Handlebars.tsx index c4305a2a8c8ba..77314c6bdea4c 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/src/Handlebars.tsx +++ b/superset-frontend/plugins/plugin-chart-handlebars/src/Handlebars.tsx @@ -22,8 +22,8 @@ import { HandlebarsViewer } from './components/Handlebars/HandlebarsViewer'; import { HandlebarsProps, HandlebarsStylesProps } from './types'; const Styles = styled.div` - padding: ${({ theme }) => theme.gridUnit * 4}px; - border-radius: ${({ theme }) => theme.gridUnit * 2}px; + padding: ${({ theme }) => theme.sizeUnit * 4}px; + border-radius: ${({ theme }) => theme.sizeUnit * 2}px; height: ${({ height }) => height}px; width: ${({ width }) => width}px; overflow: auto; diff --git a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/style.tsx b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/style.tsx index b5f8dc93827a8..df3581e6ca7ca 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/style.tsx +++ b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/style.tsx @@ -48,7 +48,7 @@ const StyleControl = (props: CustomControlConfig) => {
{props.label}
diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx index aef8b8b321262..2322c6e6f12be 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx @@ -539,7 +539,7 @@ export default function PivotTableChart(props: PivotTableProps) { ); return ( - + css` table.pvtTable { position: ${isDashboardEditMode ? 'inherit' : 'relative'}; - width: calc(100% - ${theme.gridUnit}px); - font-size: ${theme.typography.sizes.s}px; + width: calc(100% - ${theme.sizeUnit}px); + font-size: ${theme.fontSizeSM}px; text-align: left; - margin: ${theme.gridUnit}px; + margin: ${theme.sizeUnit}px; border-collapse: separate; - font-family: ${theme.typography.families.sansSerif}; + font-family: ${theme.fontFamily}; line-height: 1.4; } @@ -46,9 +46,9 @@ export const Styles = styled.div` background-color: ${theme.colors.grayscale.light5}; border-top: 1px solid ${theme.colors.grayscale.light2}; border-left: 1px solid ${theme.colors.grayscale.light2}; - font-size: ${theme.typography.sizes.s}px; - padding: ${theme.gridUnit}px; - font-weight: ${theme.typography.weights.normal}; + font-size: ${theme.fontSizeSM}px; + padding: ${theme.sizeUnit}px; + font-weight: ${theme.fontWeightNormal}; } table.pvtTable tbody tr.pvtRowTotals { @@ -94,16 +94,16 @@ export const Styles = styled.div` table.pvtTable .pvtTotalLabel { text-align: right; - font-weight: ${theme.typography.weights.bold}; + font-weight: ${theme.fontWeightStrong}; } table.pvtTable .pvtSubtotalLabel { - font-weight: ${theme.typography.weights.bold}; + font-weight: ${theme.fontWeightStrong}; } table.pvtTable tbody tr td { color: ${theme.colors.primary.dark2}; - padding: ${theme.gridUnit}px; + padding: ${theme.sizeUnit}px; background-color: ${theme.colors.grayscale.light5}; border-top: 1px solid ${theme.colors.grayscale.light2}; border-left: 1px solid ${theme.colors.grayscale.light2}; @@ -117,7 +117,7 @@ export const Styles = styled.div` .pvtTotal, .pvtGrandTotal { - font-weight: ${theme.typography.weights.bold}; + font-weight: ${theme.fontWeightStrong}; } table.pvtTable tbody tr td.pvtRowTotal { @@ -133,7 +133,7 @@ export const Styles = styled.div` } .toggle { - padding-right: ${theme.gridUnit}px; + padding-right: ${theme.sizeUnit}px; cursor: pointer; } diff --git a/superset-frontend/plugins/plugin-chart-table/src/Styles.tsx b/superset-frontend/plugins/plugin-chart-table/src/Styles.tsx index e394d16446ee3..d913a9e2ac1ee 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/Styles.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/Styles.tsx @@ -36,15 +36,15 @@ export default styled.div` thead > tr > th { padding-right: 0; position: relative; - background: ${theme.colors.grayscale.light5}; + background: ${theme.colorBgLayout}; text-align: left; } th svg { - color: ${theme.colors.grayscale.light2}; - margin: ${theme.gridUnit / 2}px; + color: ${theme.colorIcon}; + margin: ${theme.sizeUnit / 2}px; } th.is-sorted svg { - color: ${theme.colors.grayscale.base}; + color: ${theme.colorText}; } .table > tbody > tr:first-of-type > td, .table > tbody > tr:first-of-type > th { @@ -62,20 +62,20 @@ export default styled.div` text-align: right; } .dt-totals { - font-weight: ${theme.typography.weights.bold}; + font-weight: ${theme.fontWeightStrong}; } .dt-is-null { - color: ${theme.colors.grayscale.light1}; + color: ${theme.colorTextTertiary}; } td.dt-is-filter { cursor: pointer; } td.dt-is-filter:hover { - background-color: ${theme.colors.secondary.light4}; + background-color: ${theme.colorPrimaryBgHover}; } td.dt-is-active-filter, td.dt-is-active-filter:hover { - background-color: ${theme.colors.secondary.light3}; + background-color: ${theme.colorPrimaryBgHover}; } .dt-global-filter { @@ -104,7 +104,7 @@ export default styled.div` .pagination > li > span.dt-pagination-ellipsis:focus, .pagination > li > span.dt-pagination-ellipsis:hover { - background: ${theme.colors.grayscale.light5}; + background: ${theme.colorBgLayout}; } .dt-no-results { @@ -113,7 +113,7 @@ export default styled.div` } .right-border-only { - border-right: 2px solid ${theme.colors.grayscale.light2}; + border-right: 2px solid ${theme.colorBorder}; } table .right-border-only:last-child { border-right: none; diff --git a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx index 77905ea562edb..1f2e1a8c5a2a3 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx @@ -555,9 +555,9 @@ export default function TableChart(
{t( @@ -576,7 +576,7 @@ export default function TableChart( {selectedComparisonColumns.includes(column.key) && ( @@ -823,9 +823,9 @@ export default function TableChart( color: ${basicColorFormatters && basicColorFormatters[row.index][originKey]?.arrowColor === ColorSchemeEnum.Green - ? theme.colors.success.base - : theme.colors.error.base}; - margin-right: ${theme.gridUnit}px; + ? theme.colorSuccess + : theme.colorError}; + margin-right: ${theme.sizeUnit}px; `; if ( @@ -835,9 +835,9 @@ export default function TableChart( arrowStyles = css` color: ${basicColorColumnFormatters[row.index][column.key] ?.arrowColor === ColorSchemeEnum.Green - ? theme.colors.success.base - : theme.colors.error.base}; - margin-right: ${theme.gridUnit}px; + ? theme.colorSuccess + : theme.colorError}; + margin-right: ${theme.sizeUnit}px; `; } @@ -981,8 +981,8 @@ export default function TableChart( display: flex; align-items: center; & svg { - margin-left: ${theme.gridUnit}px; - color: ${theme.colors.grayscale.dark1} !important; + margin-left: ${theme.sizeUnit}px; + color: ${theme.colorText} !important; } `} > diff --git a/superset-frontend/plugins/plugin-chart-word-cloud/src/chart/WordCloud.tsx b/superset-frontend/plugins/plugin-chart-word-cloud/src/chart/WordCloud.tsx index 0e91e93f12619..7dc5d4604b076 100644 --- a/superset-frontend/plugins/plugin-chart-word-cloud/src/chart/WordCloud.tsx +++ b/superset-frontend/plugins/plugin-chart-word-cloud/src/chart/WordCloud.tsx @@ -26,7 +26,7 @@ import { Encoder, } from 'encodable'; import { - SupersetThemeProps, + SupersetTheme, withTheme, seed, CategoricalColorNamespace, @@ -80,8 +80,7 @@ const defaultProps: Required = { }; type FullWordCloudProps = WordCloudProps & - typeof defaultProps & - SupersetThemeProps; + typeof defaultProps & { theme: SupersetTheme }; const SCALE_FACTOR_STEP = 0.5; const MAX_SCALE_FACTOR = 3; @@ -106,7 +105,7 @@ class WordCloud extends PureComponent { }, defaultEncoding: { color: { value: this.props.theme.colors.grayscale.dark2 }, - fontFamily: { value: this.props.theme.typography.families.sansSerif }, + fontFamily: { value: this.props.theme.fontFamily }, fontSize: { value: 20 }, fontWeight: { value: 'bold' }, text: { value: '' }, @@ -196,15 +195,12 @@ class WordCloud extends PureComponent { cloudLayout() .size([width * scaleFactor, height * scaleFactor]) // clone the data because cloudLayout mutates input - .words(data.map(d => ({ ...d }))) + .words(data.map((d: Word) => ({ ...d }))) .padding(5) .rotate(ROTATION[rotation] || ROTATION.flat) .text((d: PlainObject) => encoder.channels.text.getValueFromDatum(d)) .font((d: PlainObject) => - encoder.channels.fontFamily.encodeDatum( - d, - this.props.theme.typography.families.sansSerif, - ), + encoder.channels.fontFamily.encodeDatum(d, this.props.theme.fontFamily), ) .fontWeight((d: PlainObject) => encoder.channels.fontWeight.encodeDatum(d, 'normal'), diff --git a/superset-frontend/scripts/compileLess.ts b/superset-frontend/scripts/compileLess.ts new file mode 100644 index 0000000000000..4c454c668b3ad --- /dev/null +++ b/superset-frontend/scripts/compileLess.ts @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import fs from 'fs'; +import path from 'path'; +import Handlebars from 'handlebars'; +import { themeObject } from 'packages/superset-ui-core/src/theme'; + +// eslint-disable no-console +Handlebars.escapeExpression = (value: string) => value; +const { theme } = themeObject; + +// Function to apply a template and generate the output +function applyTemplate(filePath: string): void { + try { + // Read the .less.hbs template + const templateContent = fs.readFileSync(filePath, 'utf-8'); + + // Compile the template + const template = Handlebars.compile(templateContent, { noEscape: true }); + + // Generate the final .less file + const result = template({ theme }); + + // Write the output to a .less file + const outputFilePath = filePath.replace('.hbs', ''); // Remove .hbs for output + fs.writeFileSync(outputFilePath, result, 'utf-8'); + console.log(`Themed .less file generated: ${outputFilePath}`); + } catch (error) { + console.error(`Failed to process template: ${filePath}`, error); + } +} + +function findHbsFiles(dir: string): string[] { + const files = fs.readdirSync(dir); + return files + .map((file: string) => { + const fullPath = path.join(dir, file); + if (fs.statSync(fullPath).isDirectory()) { + return findHbsFiles(fullPath); + } + if (fullPath.endsWith('.less.hbs')) { + return fullPath; + } + return null; + }) + .flat() + .filter((filePath: string | null): filePath is string => filePath !== null); +} + +// Find all `.less.hbs` files in the directory +const hbsFiles = findHbsFiles('src/assets/stylesheets/'); + +// Apply templates to all `.less.hbs` files found +hbsFiles.forEach((filePath: string) => applyTemplate(filePath)); diff --git a/superset-frontend/src/GlobalStyles.tsx b/superset-frontend/src/GlobalStyles.tsx index 7829f2ff58859..ad7dd93cb89ba 100644 --- a/superset-frontend/src/GlobalStyles.tsx +++ b/superset-frontend/src/GlobalStyles.tsx @@ -18,7 +18,6 @@ */ import { css } from '@superset-ui/core'; import { Global } from '@emotion/react'; -import { mix } from 'polished'; import 'react-js-cron/dist/styles.css'; export const GlobalStyles = () => ( @@ -32,7 +31,7 @@ export const GlobalStyles = () => ( h6, strong, th { - font-weight: ${theme.typography.weights.bold}; + font-weight: ${theme.fontWeightStrong}; } // CSS hack to resolve the issue caused by the invisible echart tooltip on // https://github.com/apache/superset/issues/30058 @@ -48,38 +47,11 @@ export const GlobalStyles = () => ( .ant-select-dropdown, .antd5-modal-wrap, .antd5-modal-mask { - z-index: ${theme.zIndex.max} !important; + z-index: ${theme.zIndexPopupBase} !important; } // TODO: Remove when buttons have been upgraded to Ant Design 5. // Check src/components/Modal for more info. - .ant-modal-confirm { - button { - border: none; - border-radius: ${theme.borderRadius}px; - line-height: 1.5715; - font-size: ${theme.typography.sizes.s}px; - font-weight: ${theme.typography.weights.bold}; - } - .ant-btn-primary:not(.btn-danger) { - background: ${theme.colors.primary.base}; - color: ${theme.colors.grayscale.light5}; - &:hover { - background: ${theme.colors.primary.dark1}; - } - } - .ant-btn-default:not(.btn-danger) { - background: ${theme.colors.primary.light4}; - color: ${theme.colors.primary.dark1}; - &:hover { - background: ${mix( - 0.1, - theme.colors.primary.base, - theme.colors.primary.light4, - )}; - } - } - } .column-config-popover { & .antd5-input-number { width: 100%; @@ -92,12 +64,12 @@ export const GlobalStyles = () => ( padding: 5px 10px 6px; } && .ant-tabs { - margin-top: ${theme.gridUnit * -3}px; + margin-top: ${theme.sizeUnit * -3}px; } & .ant-tabs-nav { - margin-left: ${theme.gridUnit * -4}px; - margin-right: ${theme.gridUnit * -4}px; - margin-bottom: ${theme.gridUnit * 2}px; + margin-left: ${theme.sizeUnit * -4}px; + margin-right: ${theme.sizeUnit * -4}px; + margin-bottom: ${theme.sizeUnit * 2}px; } && .ant-tabs-tab { flex: 1; diff --git a/superset-frontend/src/SqlLab/SqlLabGlobalStyles.tsx b/superset-frontend/src/SqlLab/SqlLabGlobalStyles.tsx index ef9fb8be62b97..5fa75de1bfd6a 100644 --- a/superset-frontend/src/SqlLab/SqlLabGlobalStyles.tsx +++ b/superset-frontend/src/SqlLab/SqlLabGlobalStyles.tsx @@ -26,7 +26,7 @@ export const SqlLabGlobalStyles = () => ( body { min-height: max( 100vh, - ${theme.gridUnit * 125}px + ${theme.sizeUnit * 125}px ); // Set a min height so the gutter is always visible when resizing overflow: hidden; } diff --git a/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx b/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx index 06e67fb40433d..0064b5448645c 100644 --- a/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx +++ b/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx @@ -50,12 +50,39 @@ type AceEditorWrapperProps = { const StyledAceEditor = styled(AceEditor)` ${({ theme }) => css` + color: ${theme.colorText}; && { // double class is better than !important - border: 1px solid ${theme.colors.grayscale.light2}; + border: 1px solid ${theme.colorBorder}; font-feature-settings: 'liga' off, 'calt' off; + + .ace_editor { + font-family: 'Roboto Mono', monospace; + font-size: 14px; + background-color: ${theme.colorBgContainerDisabled}; + } + .ace-github { + color: ${theme.colorText}; + } + + .ace_gutter { + background-color: ${theme.colorBgTextHover}; + color: ${theme.colorText}; + } + + .ace_cursor { + color: ${theme.colorPrimaryText}; + } + + .ace_marker-layer .ace_active-line { + background: ${theme.colorBgTextHover}; + } + + .ace_marker-layer .ace_selection { + background: ${theme.colorPrimaryBgHover}; + } } `} `; @@ -200,7 +227,7 @@ const AceEditorWrapper = ({ .ace_autocomplete { // Use !important because Ace Editor applies extra CSS at the last second // when opening the autocomplete. - width: ${theme.gridUnit * 130}px !important; + width: ${theme.sizeUnit * 130}px !important; } .ace_tooltip { @@ -208,7 +235,7 @@ const AceEditorWrapper = ({ } .ace_scroller { - background-color: ${theme.colors.grayscale.light4}; + background-color: ${theme.colorBgLayout}; } `} /> diff --git a/superset-frontend/src/SqlLab/components/App/index.tsx b/superset-frontend/src/SqlLab/components/App/index.tsx index 7da80d8e9c965..7a2ce2b94d709 100644 --- a/superset-frontend/src/SqlLab/components/App/index.tsx +++ b/superset-frontend/src/SqlLab/components/App/index.tsx @@ -45,13 +45,13 @@ const SqlLabStyles = styled.div` right: 0; bottom: 0; left: 0; - padding: 0 ${theme.gridUnit * 2}px; + padding: 0 ${theme.sizeUnit * 2}px; pre { padding: 0 !important; margin: 0; border: none; - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; background: transparent !important; } @@ -76,7 +76,7 @@ const SqlLabStyles = styled.div` .ant-tabs-content { height: 100%; position: relative; - background-color: ${theme.colors.grayscale.light5}; + background-color: ${theme.colorBgContainer}; overflow-x: auto; overflow-y: auto; @@ -90,7 +90,7 @@ const SqlLabStyles = styled.div` } .ResultsModal .antd5-modal-body { - min-height: ${theme.gridUnit * 140}px; + min-height: ${theme.sizeUnit * 140}px; } .antd5-modal-body { diff --git a/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx b/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx index 613fa5dbea0b1..3cc9d14f552d5 100644 --- a/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx +++ b/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx @@ -29,7 +29,7 @@ const StyledTooltip = (props: any) => { { background: transparent; border: none; text-align: left; - color: ${theme.colors.grayscale.light5}; - font-size: ${theme.typography.sizes.xs}px; + color: ${theme.colorBgLayout}; + font-size: ${theme.fontSizeXS}px; } } `} @@ -50,7 +50,7 @@ const StyledTooltip = (props: any) => { }; const Hr = styled.hr` - margin-top: ${({ theme }) => theme.gridUnit * 1.5}px; + margin-top: ${({ theme }) => theme.sizeUnit * 1.5}px; `; const iconMap = { diff --git a/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/index.tsx b/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/index.tsx index 4c50541afd5b8..a272ecd59d17d 100644 --- a/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/index.tsx @@ -38,7 +38,7 @@ export interface EstimateQueryCostButtonProps { const CostEstimateModalStyles = styled.div` ${({ theme }) => css` - font-size: ${theme.typography.sizes.s}; + font-size: ${theme.fontSizeSM}; `} `; diff --git a/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx b/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx index fbc71065bcfcf..da6b31b00a256 100644 --- a/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx @@ -73,23 +73,23 @@ const KeyMapByCommand = Object.entries(KEY_MAP).reduce( ); const ShortcutDescription = styled.span` - font-size: ${({ theme }) => theme.typography.sizes.m}px; - color: ${({ theme }) => theme.colors.text.help}; - padding-left: ${({ theme }) => theme.gridUnit * 2}px; + font-size: ${({ theme }) => theme.fontSize}px; + color: ${({ theme }) => theme.colorTextLabel}; + padding-left: ${({ theme }) => theme.sizeUnit * 2}px; `; const ShortcutWrapper = styled.div` display: flex; flex-wrap: wrap; - gap: ${({ theme }) => theme.gridUnit}px; - padding: ${({ theme }) => theme.gridUnit * 2}px; + gap: ${({ theme }) => theme.sizeUnit}px; + padding: ${({ theme }) => theme.sizeUnit * 2}px; `; const ShortcutCode = styled.code` - font-size: ${({ theme }) => theme.typography.sizes.s}px; - color: ${({ theme }) => theme.colors.grayscale.dark1}; + font-size: ${({ theme }) => theme.fontSizeSM}px; + color: ${({ theme }) => theme.colorText}; border-radius: ${({ theme }) => theme.borderRadius}px; - padding: ${({ theme }) => `${theme.gridUnit}px ${theme.gridUnit * 2}px`}; + padding: ${({ theme }) => `${theme.sizeUnit}px ${theme.sizeUnit * 2}px`}; `; const KeyboardShortcutButton: FC<{}> = ({ children }) => ( diff --git a/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx b/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx index df35351e5c231..fda0590107d47 100644 --- a/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx +++ b/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx @@ -38,18 +38,18 @@ const LimitSelectStyled = styled.span` ${({ theme }) => ` .ant-dropdown-trigger { align-items: center; - color: ${theme.colors.grayscale.dark2}; + color: ${theme.colorIcon}; display: flex; font-size: 12px; - margin-right: ${theme.gridUnit * 2}px; + margin-right: ${theme.sizeUnit * 2}px; text-decoration: none; border: 0; background: transparent; span { display: inline-block; - margin-right: ${theme.gridUnit * 2}px; + margin-right: ${theme.sizeUnit * 2}px; &:last-of-type: { - margin-right: ${theme.gridUnit * 4}px; + margin-right: ${theme.sizeUnit * 4}px; } } } diff --git a/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx b/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx index b11efecdd2706..1e78e8cc441e6 100644 --- a/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx +++ b/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx @@ -25,7 +25,7 @@ interface QueryStateLabelProps { } const StyledLabel = styled(Label)` - margin-right: ${({ theme }) => theme.gridUnit}px; + margin-right: ${({ theme }) => theme.sizeUnit}px; `; export default function QueryStateLabel({ query }: QueryStateLabelProps) { diff --git a/superset-frontend/src/SqlLab/components/QueryTable/index.tsx b/superset-frontend/src/SqlLab/components/QueryTable/index.tsx index 3080b84f958b0..914bab555dcb8 100644 --- a/superset-frontend/src/SqlLab/components/QueryTable/index.tsx +++ b/superset-frontend/src/SqlLab/components/QueryTable/index.tsx @@ -130,10 +130,7 @@ const QueryTable = ({ success: { config: { icon: ( - + ), // icon: , label: t('Success'), @@ -142,10 +139,7 @@ const QueryTable = ({ failed: { config: { icon: ( - + ), label: t('Failed'), }, @@ -153,10 +147,7 @@ const QueryTable = ({ stopped: { config: { icon: ( - + ), label: t('Failed'), }, @@ -165,7 +156,7 @@ const QueryTable = ({ config: { icon: ( ), @@ -176,7 +167,7 @@ const QueryTable = ({ config: { icon: ( ), @@ -185,9 +176,7 @@ const QueryTable = ({ }, timed_out: { config: { - icon: ( - - ), + icon: , label: t('Offline'), }, }, @@ -195,7 +184,7 @@ const QueryTable = ({ config: { icon: ( ), @@ -206,7 +195,7 @@ const QueryTable = ({ config: { icon: ( ), @@ -215,9 +204,7 @@ const QueryTable = ({ }, error: { config: { - icon: ( - - ), + icon: , label: t('Unknown Status'), }, }, diff --git a/superset-frontend/src/SqlLab/components/QueryTable/styles.ts b/superset-frontend/src/SqlLab/components/QueryTable/styles.ts index 2800f09945636..a1eb740964e28 100644 --- a/superset-frontend/src/SqlLab/components/QueryTable/styles.ts +++ b/superset-frontend/src/SqlLab/components/QueryTable/styles.ts @@ -31,11 +31,11 @@ export const verticalAlign = css` `; export const StyledTooltip = styled(IconTooltip)` - padding-right: ${({ theme }) => theme.gridUnit * 2}px; + padding-right: ${({ theme }) => theme.sizeUnit * 2}px; span { color: ${({ theme }) => theme.colors.grayscale.base}; &: hover { - color: ${({ theme }) => theme.colors.primary.base}; + color: ${({ theme }) => theme.colorPrimary}; } } `; diff --git a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx index db44fdda164ba..27a134332bb9e 100644 --- a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx +++ b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx @@ -110,24 +110,24 @@ export interface ResultSetProps { const ResultContainer = styled.div` display: flex; flex-direction: column; - row-gap: ${({ theme }) => theme.gridUnit * 2}px; + row-gap: ${({ theme }) => theme.sizeUnit * 2}px; `; const ResultlessStyles = styled.div` position: relative; - min-height: ${({ theme }) => theme.gridUnit * 25}px; + min-height: ${({ theme }) => theme.sizeUnit * 25}px; [role='alert'] { - margin-top: ${({ theme }) => theme.gridUnit * 2}px; + margin-top: ${({ theme }) => theme.sizeUnit * 2}px; } .sql-result-track-job { - margin-top: ${({ theme }) => theme.gridUnit * 2}px; + margin-top: ${({ theme }) => theme.sizeUnit * 2}px; } `; // Making text render line breaks/tabs as is as monospace, // but wrapping text too so text doesn't overflow const MonospaceDiv = styled.div` - font-family: ${({ theme }) => theme.typography.families.monospace}; + font-family: ${({ theme }) => theme.fontFamilyCode}; white-space: pre; word-break: break-word; overflow-x: auto; @@ -135,7 +135,7 @@ const MonospaceDiv = styled.div` `; const ReturnedRows = styled.div` - font-size: ${({ theme }) => theme.typography.sizes.s}px; + font-size: ${({ theme }) => theme.fontSizeSM}px; line-height: 1; `; @@ -147,7 +147,7 @@ const ResultSetControls = styled.div` const ResultSetButtons = styled.div` display: grid; grid-auto-flow: column; - padding-right: ${({ theme }) => 2 * theme.gridUnit}px; + padding-right: ${({ theme }) => 2 * theme.sizeUnit}px; `; const ROWS_CHIP_WIDTH = 100; @@ -497,14 +497,14 @@ const ResultSet = ({ >
@@ -962,7 +961,7 @@ const SqlEditor: FC = ({ data-test="sqlEditor-loading" css={css` flex: 1; - padding: ${theme.gridUnit * 4}px; + padding: ${theme.sizeUnit * 4}px; `} > diff --git a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx index 1e0012aed27e5..de5d5b2a6bbdd 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx +++ b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx @@ -62,7 +62,7 @@ const StyledScrollbarContainer = styled.div` const collapseStyles = (theme: SupersetTheme) => css` .ant-collapse-item { - margin-bottom: ${theme.gridUnit * 3}px; + margin-bottom: ${theme.sizeUnit * 3}px; } .ant-collapse-header { padding: 0px !important; @@ -70,15 +70,15 @@ const collapseStyles = (theme: SupersetTheme) => css` align-items: center; } .ant-collapse-content-box { - padding: 0px ${theme.gridUnit * 4}px 0px 0px !important; + padding: 0px ${theme.sizeUnit * 4}px 0px 0px !important; } .ant-collapse-arrow { padding: 0 !important; - bottom: ${theme.gridUnit}px !important; - right: ${theme.gridUnit * 4}px !important; - color: ${theme.colors.primary.dark1} !important; + bottom: ${theme.sizeUnit}px !important; + right: ${theme.sizeUnit * 4}px !important; + color: ${theme.colorPrimaryText} !important; &:hover { - color: ${theme.colors.primary.dark2} !important; + color: ${theme.colorPrimaryTextHover} !important; } } `; @@ -90,8 +90,8 @@ const LeftBarStyles = styled.div` flex-direction: column; .divider { - border-bottom: 1px solid ${theme.colors.grayscale.light4}; - margin: ${theme.gridUnit * 4}px 0; + border-bottom: 1px solid ${theme.colorBorder}; + margin: ${theme.sizeUnit * 4}px 0; } `} `; diff --git a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx index d8f4c8e4ed072..21da3887006f7 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx +++ b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx @@ -38,13 +38,13 @@ const TabTitleWrapper = styled.div` align-items: center; `; const TabTitle = styled.span` - margin-right: ${({ theme }) => theme.gridUnit * 2}px; + margin-right: ${({ theme }) => theme.sizeUnit * 2}px; text-transform: none; `; const IconContainer = styled.div` display: inline-block; - width: ${({ theme }) => theme.gridUnit * 8}px; + width: ${({ theme }) => theme.sizeUnit * 8}px; text-align: center; `; diff --git a/superset-frontend/src/SqlLab/components/TabStatusIcon/index.tsx b/superset-frontend/src/SqlLab/components/TabStatusIcon/index.tsx index da069d6cffb29..4fbde0c08ea65 100644 --- a/superset-frontend/src/SqlLab/components/TabStatusIcon/index.tsx +++ b/superset-frontend/src/SqlLab/components/TabStatusIcon/index.tsx @@ -29,28 +29,28 @@ const IconContainer = styled.span` const Circle = styled.div` ${({ theme }) => css` border-radius: 50%; - width: ${theme.gridUnit * 3}px; - height: ${theme.gridUnit * 3}px; + width: ${theme.sizeUnit * 3}px; + height: ${theme.sizeUnit * 3}px; display: inline-block; background-color: ${theme.colors.grayscale.light2}; text-align: center; vertical-align: middle; - font-size: ${theme.typography.sizes.m}px; - font-weight: ${theme.typography.weights.bold}; + font-size: ${theme.fontSize}px; + font-weight: ${theme.fontWeightStrong}; color: ${theme.colors.grayscale.light5}; position: relative; &.running { - background-color: ${theme.colors.info.base}; + background-color: ${theme.colorInfo}; } &.success { - background-color: ${theme.colors.success.base}; + background-color: ${theme.colorSuccess}; } &.failed { - background-color: ${theme.colors.error.base}; + background-color: ${theme.colorError}; } `} `; diff --git a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx index a9360ad655e32..f8a60ab1d57e5 100644 --- a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx +++ b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx @@ -51,7 +51,7 @@ const StyledTab = styled.span` `; const TabTitle = styled.span` - margin-right: ${({ theme }) => theme.gridUnit * 2}px; + margin-right: ${({ theme }) => theme.sizeUnit * 2}px; text-transform: none; `; diff --git a/superset-frontend/src/SqlLab/components/TableElement/index.tsx b/superset-frontend/src/SqlLab/components/TableElement/index.tsx index 5817e5662c5cc..bd082a5977f5d 100644 --- a/superset-frontend/src/SqlLab/components/TableElement/index.tsx +++ b/superset-frontend/src/SqlLab/components/TableElement/index.tsx @@ -57,15 +57,15 @@ export interface TableElementProps { } const StyledSpan = styled.span` - color: ${({ theme }) => theme.colors.primary.dark1}; + color: ${({ theme }) => theme.colorPrimaryText}; &:hover { - color: ${({ theme }) => theme.colors.primary.dark2}; + color: ${({ theme }) => theme.colorPrimaryTextHover}; } cursor: pointer; `; const Fade = styled.div` - transition: all ${({ theme }) => theme.transitionTiming}s; + transition: all ${({ theme }) => theme.motionDurationMid}; opacity: ${(props: { hovered: boolean }) => (props.hovered ? 1 : 0)}; `; @@ -73,7 +73,7 @@ const StyledCollapsePanel = styled(Collapse.Panel)` ${({ theme }) => css` & { .ws-el-controls { - margin-right: ${-theme.gridUnit}px; + margin-right: ${-theme.sizeUnit}px; display: flex; } @@ -87,7 +87,7 @@ const StyledCollapsePanel = styled(Collapse.Panel)` white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - font-size: ${theme.typography.sizes.l}px; + font-size: ${theme.fontSizeLG}px; flex: 1; } @@ -95,7 +95,7 @@ const StyledCollapsePanel = styled(Collapse.Panel)` margin-left: auto; display: flex; align-items: center; - margin-right: ${theme.gridUnit * 8}px; + margin-right: ${theme.sizeUnit * 8}px; } } } @@ -267,12 +267,12 @@ const TableElement = ({ table, ...props }: TableElementProps) => { return ( diff --git a/superset-frontend/src/SqlLab/constants.ts b/superset-frontend/src/SqlLab/constants.ts index 5a944663b8a69..008eab1526f41 100644 --- a/superset-frontend/src/SqlLab/constants.ts +++ b/superset-frontend/src/SqlLab/constants.ts @@ -20,12 +20,12 @@ import { t } from '@superset-ui/core'; import type { Type } from 'src/components/Label'; export const STATE_TYPE_MAP: Record = { - offline: 'danger', - failed: 'danger', + offline: 'error', + failed: 'error', pending: 'info', fetching: 'info', running: 'warning', - stopped: 'danger', + stopped: 'error', success: 'success', }; diff --git a/superset-frontend/src/assets/stylesheets/antd/index.less b/superset-frontend/src/assets/stylesheets/antd/index.less index cf51b165eb998..db2622f186239 100644 --- a/superset-frontend/src/assets/stylesheets/antd/index.less +++ b/superset-frontend/src/assets/stylesheets/antd/index.less @@ -10,30 +10,128 @@ * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + * OF ANY KIND, either express or implied. See the License + * for the specific language governing permissions and + * limitations under the License. */ +// @ant-prefix: antd4; -@import '~antd/lib/style/themes/index'; +// Core styles and dependencies +@import '~antd/lib/style/themes/default.less'; // Use default theme instead of index @import '~antd/lib/style/mixins/index'; -@import '~antd/lib/style/core/base'; +// Base styles with prefix +@import '~antd/lib/style/core/base'; @import '~antd/lib/style/core/iconfont'; @import '~antd/lib/style/core/motion'; + +// All component styles @import '~antd/lib/style/components.less'; + /* Theme variables here: https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less */ -@primary-color: #20a7c9; -@info-color: #66bcfe; -@success-color: #59c189; -@processing-color: #66bcfe; -@error-color: #e04355; -@highlight-color: #e04355; -@normal-color: #d9d9d9; -@white: #fff; -@black: #000; +/* Core Colors */ +@primary-color: #1e91ae; +@info-color: #5aa3db; +@processing-color: #858585; +@success-color: #50a777; +@error-color: #c13c4b; +@highlight-color: #c13c4b; +@normal-color: #1f1f1f; + +// Menu-related +@menu-highlight-color: #1e91ae; +@menu-item-active-bg: ; +@menu-item-color: #78bdce; +@menu-popup-bg: #141414; +@menu-bg: #141414; + +@tabs-card-head-background: #1f1f1f; +@component-background: #141414; +@select-item-selected-bg: #121f24; +@select-item-active-bg: #121f24; +@select-item-hover-bg: #121f24; + +@item-hover-bg: #1f1f1f; +@menu-item-hover-bg: #1f1f1f; + +// GPT generated: + +/* Backgrounds */ +@layout-body-background: #000000; +@layout-header-background: #141414; +@layout-footer-background: #141414; +@layout-sider-background: #141414; +@background-color-light: #141414; +@background-color-base: #141414; +@background-elevated: #1f1f1f; + +/* Text */ +@text-color: rgba(255, 255, 255, 0.85); +@text-color-secondary: rgba(255, 255, 255, 0.65); +@text-color-tertiary: rgba(255, 255, 255, 0.45); +@text-color-quaternary: rgba(255, 255, 255, 0.25); +@heading-color: #141414; +@disabled-color: rgba(255, 255, 255, 0.65); +@input-placeholder-color: rgba(255, 255, 255, 0.65); + +/* Borders */ +@border-color-base: #424242; +@border-color-split: #303030; +@border-radius-base: 6; +@border-radius-sm: 4; +@border-radius-lg: 8; + +/* Buttons */ +@btn-primary-bg: #1e91ae; +@btn-default-bg: #141414; +@btn-default-border: #424242; +@btn-danger-bg: #c13c4b; +@btn-danger-border: #c13c4b; + +/* Inputs */ +//@input-bg: ; +@input-border-color: #424242; +@input-hover-border-color: #195665; + +/* Menus */ +@menu-bg: #141414; +@menu-popup-bg: #141414; +@menu-item-color: rgba(255, 255, 255, 0.85); +@menu-inline-submenu-bg: #141414; +@menu-highlight-color: rgba(255, 255, 255, 0.85); +@menu-highlight-danger-color: #c13c4b; +@menu-item-active-bg: #1e91ae; +@menu-item-active-danger-bg: #271619; +@menu-item-group-title-color: rgba(255, 255, 255, 0.85); + +/* Typography */ +@font-family: 'Inter', Helvetica, Arial; +@font-family-code: 'Fira Code', 'Courier New', monospace; +@font-size-base: 14px; +@font-size-sm: 12px; +@font-size-lg: 16px; +@line-height-base: 1.5714285714285714; +@line-height-sm: 1.6666666666666667; +@line-height-lg: 1.5; + +/* Tables */ +@table-header-bg: #141414; +@table-row-hover-bg: #1f1f1f; +@table-selected-row-bg: #121f24; + +/* Motion */ +@motion-duration-fast: 0.1s; +@motion-duration-mid: 0.2s; +@motion-duration-slow: 0.3s; +@motion-ease-out: cubic-bezier(0.215, 0.61, 0.355, 1); +@motion-ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1); + +/* headers */ +@heading-color: rgba(255, 255, 255, 0.85); +@collapse-header-bg: #141414; +@collapse-header-padding: 4px 4px; diff --git a/superset-frontend/src/assets/stylesheets/antd/index.less.hbs b/superset-frontend/src/assets/stylesheets/antd/index.less.hbs new file mode 100644 index 0000000000000..616376c60f3ac --- /dev/null +++ b/superset-frontend/src/assets/stylesheets/antd/index.less.hbs @@ -0,0 +1,137 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + * OF ANY KIND, either express or implied. See the License + * for the specific language governing permissions and + * limitations under the License. + */ +// @ant-prefix: antd4; + +// Core styles and dependencies +@import '~antd/lib/style/themes/default.less'; // Use default theme instead of index +@import '~antd/lib/style/mixins/index'; + +// Base styles with prefix +@import '~antd/lib/style/core/base'; +@import '~antd/lib/style/core/iconfont'; +@import '~antd/lib/style/core/motion'; + +// All component styles +@import '~antd/lib/style/components.less'; + + +/* + Theme variables here: https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less +*/ +/* Core Colors */ +@primary-color: {{theme.colorPrimary}}; +@info-color: {{theme.colorInfo}}; +@processing-color: {{theme.colors.grayscale.dark2}}; +@success-color: {{theme.colorSuccess}}; +@error-color: {{theme.colorError}}; +@highlight-color: {{theme.colorError}}; +@normal-color: {{theme.colors.grayscale.light3}}; + +// Menu-related +@menu-highlight-color: {{theme.colorPrimary}}; +@menu-item-active-bg: {{theme.colorElevated}}; +@menu-item-color: {{theme.colors.primary.dark3}}; +@menu-popup-bg: {{theme.colorBgContainer}}; +@menu-bg: {{theme.colorBgContainer}}; + +@tabs-card-head-background: {{theme.colorBgElevated}}; +@component-background: {{theme.colorBgContainer}}; +@select-item-selected-bg: {{theme.colorPrimaryBg}}; +@select-item-active-bg: {{theme.colorPrimaryBg}}; +@select-item-hover-bg: {{theme.colorPrimaryBg}}; + +@item-hover-bg: {{theme.colorBgElevated}}; +@menu-item-hover-bg: {{theme.colorBgElevated}}; + +// GPT generated: + +/* Backgrounds */ +@layout-body-background: {{theme.colorBgLayout}}; +@layout-header-background: {{theme.colorBgContainer}}; +@layout-footer-background: {{theme.colorBgContainer}}; +@layout-sider-background: {{theme.colorBgContainer}}; +@background-color-light: {{theme.colorBgContainer}}; +@background-color-base: {{theme.colorBgContainer}}; +@background-elevated: {{theme.colorBgElevated}}; + +/* Text */ +@text-color: {{theme.colorText}}; +@text-color-secondary: {{theme.colorTextSecondary}}; +@text-color-tertiary: {{theme.colorTextTertiary}}; +@text-color-quaternary: {{theme.colorTextQuaternary}}; +@heading-color: {{theme.colorBgContainer}}; +@disabled-color: {{theme.colorTextSecondary}}; +@input-placeholder-color: {{theme.colorTextSecondary}}; + +/* Borders */ +@border-color-base: {{theme.colorBorder}}; +@border-color-split: {{theme.colorBorderSecondary}}; +@border-radius-base: {{theme.borderRadius}}; +@border-radius-sm: {{theme.borderRadiusSM}}; +@border-radius-lg: {{theme.borderRadiusLG}}; + +/* Buttons */ +@btn-primary-bg: {{theme.colorPrimary}}; +@btn-default-bg: {{theme.colorBgContainer}}; +@btn-default-border: {{theme.colorBorder}}; +@btn-danger-bg: {{theme.colorError}}; +@btn-danger-border: {{theme.colorError}}; + +/* Inputs */ +//@input-bg: {{theme.colorBgInput}}; +@input-border-color: {{theme.colorBorder}}; +@input-hover-border-color: {{theme.colorPrimaryBorderHover}}; + +/* Menus */ +@menu-bg: {{theme.colorBgContainer}}; +@menu-popup-bg: {{theme.colorBgContainer}}; +@menu-item-color: {{theme.colorText}}; +@menu-inline-submenu-bg: {{theme.colorBgContainer}}; +@menu-highlight-color: {{theme.colorText}}; +@menu-highlight-danger-color: {{theme.colorError}}; +@menu-item-active-bg: {{theme.colorPrimary}}; +@menu-item-active-danger-bg: {{theme.colorErrorBg}}; +@menu-item-group-title-color: {{theme.colorText}}; + +/* Typography */ +@font-family: {{theme.fontFamily}}; +@font-family-code: {{theme.fontFamilyCode}}; +@font-size-base: {{theme.fontSize}}px; +@font-size-sm: {{theme.fontSizeSM}}px; +@font-size-lg: {{theme.fontSizeLG}}px; +@line-height-base: {{theme.lineHeight}}; +@line-height-sm: {{theme.lineHeightSM}}; +@line-height-lg: {{theme.lineHeightLG}}; + +/* Tables */ +@table-header-bg: {{theme.colorBgContainer}}; +@table-row-hover-bg: {{theme.colorBgElevated}}; +@table-selected-row-bg: {{theme.colorPrimaryBg}}; + +/* Motion */ +@motion-duration-fast: {{theme.motionDurationFast}}; +@motion-duration-mid: {{theme.motionDurationMid}}; +@motion-duration-slow: {{theme.motionDurationSlow}}; +@motion-ease-out: {{theme.motionEaseOut}}; +@motion-ease-in-out: {{theme.motionEaseInOut}}; + +/* headers */ +@heading-color: {{theme.colorText}}; +@collapse-header-bg: {{theme.colorBgContainer}}; +@collapse-header-padding: {{theme.sizeUnit}}px {{theme.sizeUnit}}px; diff --git a/superset-frontend/src/assets/stylesheets/less/cosmo/bootswatch.less.hbs b/superset-frontend/src/assets/stylesheets/less/cosmo/bootswatch.less.hbs new file mode 100644 index 0000000000000..c9ece15bb6639 --- /dev/null +++ b/superset-frontend/src/assets/stylesheets/less/cosmo/bootswatch.less.hbs @@ -0,0 +1,509 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +// Forked Cosmo 3.3.7 +// Bootswatch +// ----------------------------------------------------- + +// Navbar ===================================================================== + +.navbar { + border: none; + + li > a:focus { + outline: 0; + } + + &-inverse { + .badge { + background-color: @lightest; + color: @brand-primary; + } + } + + .caret { + display: inline-block; + padding: 0 5px 18px 5px; + } +} + +.navbar-inverse { + border: none; +} + +.navbar-inverse .navbar-nav > .active > a, +.navbar-inverse .navbar-nav > .active > a:hover, +.navbar-inverse .navbar-nav > .active > a:focus { + background: transparent; +} + +.navbar-nav > li > a { + padding-top: 18px; +} + +// Buttons ==================================================================== + +.btn:focus, +.btn:active:focus { + outline: none; +} + +.nav-tabs { + .dropdown-toggle.btn, + .btn-group.open .dropdown-toggle.btn { + &, + &:hover, + &:active, + &:focus { + border-color: transparent; + background-color: transparent; + box-shadow: none; + } + } +} + +.caret { + border: none; + color: @gray; + + &:hover { + color: @gray-darker; + } + + &:before { + font-family: 'FontAwesome'; + font-size: @font-size-xs; + content: '\f078'; + } +} + +// Typography ================================================================= + +body { + -webkit-font-smoothing: antialiased; +} + +.text-primary, +.text-primary:hover { + color: @brand-primary; +} + +.text-success, +.text-success:hover { + color: @success; +} + +.text-danger, +.text-danger:hover { + color: @brand-danger; +} + +.text-warning, +.text-warning:hover { + color: @brand-warning; +} + +.text-info, +.text-info:hover { + color: @brand-info; +} + +// Tables ===================================================================== + +table, +.table { + .dropdown-menu a { + text-decoration: none; + } + + .success, + .warning, + .danger, + .info { + color: @lightest; + + a { + color: @lightest; + } + + .btn-default { + color: @gray; + } + } +} + +// Forms ====================================================================== + +.form-control { + box-shadow: none; +} + +.has-warning { + .help-block, + .control-label, + .radio, + .checkbox, + .radio-inline, + .checkbox-inline, + &.radio label, + &.checkbox label, + &.radio-inline label, + &.checkbox-inline label, + .form-control-feedback { + color: @brand-warning; + } + + .form-control, + .form-control:focus, + .input-group-addon { + border: 1px solid @brand-warning; + } +} + +.has-error { + .help-block, + .control-label, + .radio, + .checkbox, + .radio-inline, + .checkbox-inline, + &.radio label, + &.checkbox label, + &.radio-inline label, + &.checkbox-inline label, + .form-control-feedback { + color: @brand-danger; + } + + .form-control, + .form-control:focus, + .input-group-addon { + border: 1px solid @brand-danger; + } +} + +.has-success { + .help-block, + .control-label, + .radio, + .checkbox, + .radio-inline, + .checkbox-inline, + &.radio label, + &.checkbox label, + &.radio-inline label, + &.checkbox-inline label, + .form-control-feedback { + color: @brand-success; + } + + .form-control, + .form-control:focus, + .input-group-addon { + border: 1px solid @brand-success; + } +} + +// Navs ======================================================================= + +.nav-pills { + & > li > a { + border-radius: @border-radius-normal; + } +} + +.dropdown-menu { + & > li > a:hover, + & > li > a:focus { + background-image: none; + text-decoration: none; + } +} + +// Indicators ================================================================= + +.close { + text-decoration: none; + text-shadow: none; + opacity: 0.4; + + &:hover, + &:focus { + opacity: 1; + } +} + +.alert { + border: none; +} + +.alert-link { + text-decoration: underline; +} + +.alert-info .alert-link { + color: @alert-info-text; +} + +.alert-danger .alert-link { + color: @alert-danger-text; +} + +.alert-warning .alert-link { + color: @alert-warning-text; +} + +.alert-success .alert-link { + color: @alert-success-text; +} + +.label { + border-radius: 21px; + padding: 0.35em 0.8em 0.35em; + font-weight: @font-weight-normal; + font-size: @font-size-s; +} +.label-default:hover { + background-color: darken(@label-default-bg, 5%); +} +.label-warning:hover { + background-color: darken(@label-warning-bg, 5%); +} +.label-danger:hover { + background-color: darken(@label-danger-bg, 5%); +} +.label-primary:hover { + background-color: darken(@label-primary-bg, 5%); +} + +label { + font-weight: @font-weight-normal; + font-size: @font-size-s; +} + +// Progress bars ============================================================== + +.progress { + height: 14px; + .box-shadow(none); + + .progress-bar { + font-size: @font-size-s; + line-height: @line-height-tight; + padding-top: 2px; + } +} + +// Containers ================================================================= + +.panel { + border: none; + + &-heading, + &-footer { + border-top-right-radius: 0; + border-top-left-radius: 0; + } + + &-default { + .panel-heading { + padding: 15px 15px 0 15px; + background-color: transparent; + } + + .panel-title { + color: @text-color; + padding-bottom: 5px; + border-bottom: 1px solid @gray-light; + + h1, + h2, + h3, + h4, + h5, + h6 { + margin: 10px 0 0 0; + font-weight: @font-weight-bold; + } + } + + .close { + color: @text-color; + } + } + + &-primary { + .panel-heading { + padding: 15px 15px 0 15px; + background-color: transparent; + } + + .panel-title { + color: @text-color; + padding-bottom: 5px; + border-bottom: 1px solid @gray-light; + + h1, + h2, + h3, + h4, + h5, + h6 { + margin: 10px 0 0 0; + font-weight: @font-weight-bold; + } + } + + .close { + color: @text-color; + } + } + + .accordion-toggle { + display: flex; + align-items: center; + text-decoration: none; + + &:hover { + text-decoration: none; + } + + .caret { + display: flex; + width: auto; + height: auto; + margin-left: 5px; + + &:hover { + color: @gray; + } + } + } +} + +.panel-title-large { + font-size: 24px; +} + +.list-group-item { + padding-top: 5px; + padding-bottom: 5px; +} + +a.list-group-item { + &-success { + &.active { + background-color: @state-success-bg; + } + + &.active:hover, + &.active:focus { + background-color: darken(@state-success-bg, 5%); + } + } + + &-warning { + &.active { + background-color: @state-warning-bg; + } + + &.active:hover, + &.active:focus { + background-color: darken(@state-warning-bg, 5%); + } + } + + &-danger { + &.active { + background-color: @state-danger-bg; + } + + &.active:hover, + &.active:focus { + background-color: darken(@state-danger-bg, 5%); + } + } +} + +.modal { + .close { + color: @text-color; + } +} + +.popover { + color: @text-color; +} + +// Tabs ============================================================== + +.nav-tabs > li > a { + border-top: 3px solid transparent; + color: @text-color; +} + +.nav-tabs > li.active > a, +.nav-tabs > li.active > a:hover, +.nav-tabs > li.active > a:focus { + background-color: @lightest; + font-weight: @font-weight-bold; + border-top: 3px solid @brand-primary; +} + +// Tables ============================================================== + +.table { + .info { + color: @state-info-text; + } + + .danger { + color: @state-danger-text; + } + + .warning { + color: @state-warning-text; + } + + .success { + color: @state-success-text; + } +} + +// Utils ============================================================== +hr { + margin: 10px 0; +} + +// generate space-n classes for vertical spacing +.space-loop(@counter) when (@counter > 0) { + .space-loop((@counter - 1)); // next iteration + .space-@{counter} { + margin-bottom: (10px * @counter); // code for each iteration + } +} +.space-loop(6); + +a { + cursor: pointer; +} + +.control-label { + color: @gray; + font-size: @font-size-s; +} diff --git a/superset-frontend/src/assets/stylesheets/less/cosmo/variables.less b/superset-frontend/src/assets/stylesheets/less/cosmo/variables.less index a3c74f712cb0a..0d3bcf63b3e5c 100644 --- a/superset-frontend/src/assets/stylesheets/less/cosmo/variables.less +++ b/superset-frontend/src/assets/stylesheets/less/cosmo/variables.less @@ -24,7 +24,7 @@ // // ## Gray and brand colors for use across Bootstrap. -@gray-base: @darkest; // superset-var +@gray-base: #e0e0e0; // superset-var @gray-darker: lighten(@gray-base, 13.5%); @gray-dark: lighten(@gray-base, 20%); @bs-gray: lighten(@gray-base, 33.5%); @@ -42,9 +42,9 @@ // ## Settings for some of the most global styles. // ** Background color for ``. -@body-bg: @gray-bg; // superset-var +@body-bg: #141414; // ** Global text color on ``. -@text-color: @gray-dark; +@text-color: #a3a3a3; // ** Global textual link color. @link-color: @link; @@ -514,9 +514,9 @@ // ** Tooltip max width @tooltip-max-width: 200px; // ** Tooltip text color -@tooltip-color: @lightest; // superset-var +@tooltip-color: #525252; // superset-var // ** Tooltip background color -@tooltip-bg: @darkest; // superset-var +@tooltip-bg: rgba(255, 255, 255, 0.85); @tooltip-opacity: 0.9; // ** Tooltip arrow width @@ -812,7 +812,7 @@ // // ## -@code-color: darken(@info, @colorstop-one); +@code-color: darken(@info, 10%); @code-bg: @gray-bg; // superset-var @kbd-color: @lightest; // superset-var diff --git a/superset-frontend/src/assets/stylesheets/less/cosmo/variables.less.hbs b/superset-frontend/src/assets/stylesheets/less/cosmo/variables.less.hbs new file mode 100644 index 0000000000000..4ba7da9ce62b5 --- /dev/null +++ b/superset-frontend/src/assets/stylesheets/less/cosmo/variables.less.hbs @@ -0,0 +1,851 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +// Forked Cosmo 3.3.7 +// Variables +// -------------------------------------------------- + +// == Colors +// +// ## Gray and brand colors for use across Bootstrap. + +@gray-base: {{theme.colors.grayscale.dark5}}; // superset-var +@gray-darker: lighten(@gray-base, 13.5%); +@gray-dark: lighten(@gray-base, 20%); +@bs-gray: lighten(@gray-base, 33.5%); +@bs-gray-light: lighten(@gray-base, 60%); +@gray-lighter: lighten(@gray-base, 95%); + +@brand-primary: @primary-color; // superset-var +@brand-success: @success; // superset-var +@brand-info: @info; // superset-var +@brand-warning: @warning; // superset-var +@brand-danger: @danger; // superset-var + +// == Scaffolding +// +// ## Settings for some of the most global styles. + +// ** Background color for ``. +@body-bg: {{theme.colorBgContainer}}; +// ** Global text color on ``. +@text-color: {{theme.colors.grayscale.dark3}}; + +// ** Global textual link color. +@link-color: @link; +// ** Link hover color set via `darken()` function. +@link-hover-color: @link-hover; +// ** Link hover decoration. +@link-hover-decoration: underline; + +// == Typography +// +// ## Font, line-height, and color for body text, headings, and more. + +@font-size-large: ceil((@font-size-base * 1.25)); // ~18px +@font-size-small: ceil((@font-size-base * 0.85)); // ~12px + +@font-size-h1: floor((@font-size-base * 2.6)); // ~36px +@font-size-h2: floor((@font-size-base * 2.15)); // ~30px +@font-size-h3: ceil((@font-size-base * 1.7)); // ~24px +@font-size-h4: ceil((@font-size-base * 1.25)); // ~18px +@font-size-h5: @font-size-base; +@font-size-h6: ceil((@font-size-base * 0.85)); // ~12px + +// ** Computed "line-height" (`font-size` * `line-height`) for use with `margin`, `padding`, etc. +@line-height-computed: floor((@font-size-base * @line-height-base)); + +// ** By default, this inherits from the ``. +@headings-font-family: @font-family-base; +@headings-font-weight: @font-weight-normal; // superset-var +@headings-line-height: @line-height-tight; +@headings-color: inherit; + +// == Iconography +// +// ## Specify custom location and filename of the included Glyphicons icon font. Useful for those including Bootstrap via Bower. + +// ** Load fonts from this directory. +@icon-font-path: '../fonts/'; +// ** File name for all font files. +@icon-font-name: 'glyphicons-halflings-regular'; +// ** Element ID within SVG icon file. +@icon-font-svg-id: 'glyphicons_halflingsregular'; + +// == Components +// +// ## Define common padding and border radius sizes and more. Values based on 14px text and 1.428 line-height (~20px to start). + +@padding-base-vertical: 6.5px; +@padding-base-horizontal: 18px; + +@padding-large-vertical: 18px; +@padding-large-horizontal: 30px; + +@padding-small-vertical: 5px; +@padding-small-horizontal: 10px; + +@padding-xs-vertical: 1px; +@padding-xs-horizontal: 5px; + +@line-height-large: 1.3333333; // extra decimals for Win 8.1 Chrome +@line-height-small: 1.5; + +@border-radius-base: @border-radius-normal; +@border-radius-large: 4px; +@border-radius-small: 4px; + +// ** Global color for active items (e.g., navs or dropdowns). +@component-active-color: @lightest; // superset-var +// ** Global background color for active items (e.g., navs or dropdowns). +@component-active-bg: @brand-primary; + +// ** Width of the `border` for generating carets that indicate dropdowns. +@caret-width-base: 4px; +// ** Carets increase slightly in size for larger components. +@caret-width-large: 5px; + +// == Tables +// +// ## Customizes the `.table` component with basic values, each used across all table variations. + +// ** Padding for ``s and ``s. +@table-cell-padding: 8px; +// ** Padding for cells in `.table-condensed`. +@table-condensed-cell-padding: 5px; + +// ** Default background color used for all tables. +@table-bg: transparent; +// ** Background color used for `.table-striped`. +@table-bg-accent: fade(@gray-bg, @opacity-medium-light); // superset-var +// ** Background color used for `.table-hover`. +@table-bg-hover: @gray-bg; // superset-var +@table-bg-active: @table-bg-hover; + +// ** Border color for table and cell borders. +@table-border-color: @gray-light; // superset-var + +// == Buttons +// +// ## For each of Bootstrap's buttons, define text, background and border color. + +@btn-font-weight: normal; + +@btn-primary-color: @lightest; +@btn-primary-bg: @brand-primary; +@btn-primary-border: @brand-primary; + +@btn-default-color: @bs-gray; +@btn-default-bg: @lightest; +@btn-default-border: @gray-light; + +@btn-success-color: @btn-primary-color; +@btn-success-bg: @brand-success; +@btn-success-border: @btn-success-bg; + +@btn-info-color: @btn-primary-color; +@btn-info-bg: @brand-info; +@btn-info-border: @btn-info-bg; + +@btn-warning-color: @btn-primary-color; +@btn-warning-bg: @brand-warning; +@btn-warning-border: @btn-warning-bg; + +@btn-danger-color: @btn-primary-color; +@btn-danger-bg: @brand-danger; +@btn-danger-border: @btn-danger-bg; + +@btn-link-disabled-color: @bs-gray-light; + +// Allows for customizing button radius independently from global border radius +@btn-border-radius-base: @border-radius-base; +@btn-border-radius-large: @border-radius-large; +@btn-border-radius-small: @border-radius-small; + +// == Forms +// +// ## + +// ** `` background color +@input-bg: @lightest; // superset-var +// ** `` background color +@input-bg-disabled: @gray-lighter; + +// ** Text color for ``s +@input-color: @text-color; +// ** `` border color +@input-border: @gray-light; // superset-var + +// TODO: Rename `@input-border-radius` to `@input-border-radius-base` in v4 +// ** Default `.form-control` border radius +// This has no effect on ``s in CSS. +@input-border-radius: @border-radius-base; +// ** Large `.form-control` border radius +@input-border-radius-large: @border-radius-large; +// ** Small `.form-control` border radius +@input-border-radius-small: @border-radius-small; + +// ** Border color for inputs on focus +@input-border-focus: @indicator-color; // superset-var + +// ** Placeholder text color +@input-color-placeholder: @bs-gray-light; + +// ** Default `.form-control` height +@input-height-base: (@line-height-computed + (@padding-base-vertical * 2) + 2); +// ** Large `.form-control` height +@input-height-large: ( + ceil(@font-size-large * @line-height-large) + (@padding-large-vertical * 2) + + 2 +); +// ** Small `.form-control` height +@input-height-small: ( + floor(@font-size-small * @line-height-small) + (@padding-small-vertical * 2) + + 2 +); + +// ** `.form-group` margin +@form-group-margin-bottom: 16px; + +@legend-color: @text-color; +@legend-border-color: @gray-bg; + +// ** Background color for textual input addons +@input-group-addon-bg: @gray-lighter; +// ** Border color for textual input addons +@input-group-addon-border-color: @input-border; + +// ** Disabled cursor for form controls and buttons. +@cursor-disabled: not-allowed; + +// == Dropdowns +// +// ## Dropdown menu container and contents. + +// ** Background for the dropdown menu. +@dropdown-bg: @lightest; // superset-var +// ** Dropdown menu `border-color`. +@dropdown-border: fade(@darkest, @opacity-light); // superset-var +// ** Dropdown menu `border-color` **for IE8**. +@dropdown-fallback-border: @gray-light; // superset-var +// ** Divider color for between dropdown items. +@dropdown-divider-bg: @gray-bg; // superset-var + +// ** Dropdown link text color. +@dropdown-link-color: @gray-dark; +// ** Hover color for dropdown links. +@dropdown-link-hover-color: @lightest; // superset-var +// ** Hover background for dropdown links. +@dropdown-link-hover-bg: @component-active-bg; + +// ** Active dropdown menu item text color. +@dropdown-link-active-color: @lightest; // superset-var +// ** Active dropdown menu item background color. +@dropdown-link-active-bg: @component-active-bg; + +// ** Disabled dropdown menu item background color. +@dropdown-link-disabled-color: @bs-gray-light; + +// ** Text color for headers within dropdown menus. +@dropdown-header-color: @bs-gray-light; + +// ** Deprecated `@dropdown-caret-color` as of v3.1.0 +@dropdown-caret-color: @darkest; // superset-var + +//-- Z-index master list +// +// Warning: Avoid customizing these values. They're used for a bird's eye view +// of components dependent on the z-axis and are designed to all work together. +// +// Note: These variables are not generated into the Customizer. + +@zindex-navbar: 1000; +@zindex-dropdown: 1000; +@zindex-popover: 1060; +@zindex-tooltip: 1070; +@zindex-navbar-fixed: 1030; +@zindex-modal-background: 1040; +@zindex-modal: 1050; + +// == Media queries breakpoints +// +// ## Define the breakpoints at which your layout will change, adapting to different screen sizes. + +// Extra small screen / phone +// ** Deprecated `@screen-xs` as of v3.0.1 +@screen-xs: 480px; +// ** Deprecated `@screen-xs-min` as of v3.2.0 +@screen-xs-min: @screen-xs; +// ** Deprecated `@screen-phone` as of v3.0.1 +@screen-phone: @screen-xs-min; + +// Small screen / tablet +// ** Deprecated `@screen-sm` as of v3.0.1 +@screen-sm: 768px; +@screen-sm-min: @screen-sm; +// ** Deprecated `@screen-tablet` as of v3.0.1 +@screen-tablet: @screen-sm-min; + +// Medium screen / desktop +// ** Deprecated `@screen-md` as of v3.0.1 +@screen-md: 992px; +@screen-md-min: @screen-md; +// ** Deprecated `@screen-desktop` as of v3.0.1 +@screen-desktop: @screen-md-min; + +// Large screen / wide desktop +// ** Deprecated `@screen-lg` as of v3.0.1 +@screen-lg: 1200px; +@screen-lg-min: @screen-lg; +// ** Deprecated `@screen-lg-desktop` as of v3.0.1 +@screen-lg-desktop: @screen-lg-min; + +// So media queries don't overlap when required, provide a maximum +@screen-xs-max: (@screen-sm-min - 1); +@screen-sm-max: (@screen-md-min - 1); +@screen-md-max: (@screen-lg-min - 1); + +// == Grid system +// +// ## Define your custom responsive grid. + +// ** Number of columns in the grid. +@grid-columns: 12; +// ** Padding between columns. Gets divided in half for the left and right. +@grid-gutter-width: 20px; +// Navbar collapse +// ** Point at which the navbar becomes uncollapsed. +@grid-float-breakpoint: @screen-sm-min; +// ** Point at which the navbar begins collapsing. +@grid-float-breakpoint-max: (@grid-float-breakpoint - 1); + +// == Container sizes +// +// ## Define the maximum width of `.container` for different screen sizes. + +// Small screen / tablet +@container-tablet: (720px + @grid-gutter-width); +// ** For `@screen-sm-min` and up. +@container-sm: @container-tablet; + +// Medium screen / desktop +@container-desktop: (940px + @grid-gutter-width); +// ** For `@screen-md-min` and up. +@container-md: @container-desktop; + +// Large screen / wide desktop +@container-large-desktop: (1140px + @grid-gutter-width); +// ** For `@screen-lg-min` and up. +@container-lg: @container-large-desktop; + +// == Navbar +// +// ## + +// Basics of a navbar +@navbar-height: 50px; +@navbar-margin-bottom: @line-height-computed; +@navbar-border-radius: @border-radius-base; +@navbar-padding-horizontal: floor((@grid-gutter-width / 2)); +@navbar-padding-vertical: ((@navbar-height - @line-height-computed) / 2); +@navbar-collapse-max-height: 340px; + +@navbar-default-color: @lightest; // superset-var +@navbar-default-bg: @gray-darker; +@navbar-default-border: darken(@navbar-default-bg, 6.5%); + +// Navbar links +@navbar-default-link-color: @lightest; // superset-var +@navbar-default-link-hover-color: @lightest; // superset-var +@navbar-default-link-hover-bg: darken(@navbar-default-bg, 10%); +@navbar-default-link-active-color: @navbar-default-link-hover-color; +@navbar-default-link-active-bg: @navbar-default-link-hover-bg; +@navbar-default-link-disabled-color: @gray-light; // superset-var +@navbar-default-link-disabled-bg: transparent; + +// Navbar brand label +@navbar-default-brand-color: @navbar-default-link-color; +@navbar-default-brand-hover-color: @lightest; // superset-var +@navbar-default-brand-hover-bg: none; + +// Navbar toggle +@navbar-default-toggle-hover-bg: @navbar-default-link-hover-bg; +@navbar-default-toggle-icon-bar-bg: @lightest; // superset-var +@navbar-default-toggle-border-color: transparent; + +// === Inverted navbar +// Reset inverted navbar basics +@navbar-inverse-color: @gray-dark; +@navbar-inverse-bg: @lightest; // superset-var +@navbar-inverse-border: transparent; + +// Inverted navbar links +@navbar-inverse-link-color: @gray-dark; +@navbar-inverse-link-hover-color: @gray-dark; +@navbar-inverse-link-hover-bg: darken(@navbar-inverse-bg, 10%); +@navbar-inverse-link-active-color: @navbar-inverse-link-hover-color; +@navbar-inverse-link-active-bg: @navbar-inverse-link-hover-bg; +@navbar-inverse-link-disabled-color: @gray-lighter; +@navbar-inverse-link-disabled-bg: transparent; + +// Inverted navbar brand label +@navbar-inverse-brand-color: @navbar-inverse-link-color; +@navbar-inverse-brand-hover-color: @gray-darker; +@navbar-inverse-brand-hover-bg: none; + +// Inverted navbar toggle +@navbar-inverse-toggle-hover-bg: @navbar-inverse-link-hover-bg; +@navbar-inverse-toggle-icon-bar-bg: @lightest; // superset-var +@navbar-inverse-toggle-border-color: transparent; + +// == Navs +// +// ## + +// === Shared nav styles +@nav-link-padding: 10px 15px; +@nav-link-hover-bg: @gray-lighter; + +@nav-disabled-link-color: @bs-gray-light; +@nav-disabled-link-hover-color: @bs-gray-light; + +// == Tabs +@nav-tabs-border-color: @gray-light; // superset-var + +@nav-tabs-link-hover-border-color: @gray-lighter; + +@nav-tabs-active-link-hover-bg: @body-bg; +@nav-tabs-active-link-hover-color: @bs-gray; +@nav-tabs-active-link-hover-border-color: @gray-light; // superset-var + +@nav-tabs-justified-link-border-color: @gray-light; // superset-var +@nav-tabs-justified-active-link-border-color: @body-bg; + +// == Pills +@nav-pills-border-radius: @border-radius-base; +@nav-pills-active-link-hover-bg: @component-active-bg; +@nav-pills-active-link-hover-color: @component-active-color; + +// == Pagination +// +// ## + +@pagination-color: @link-color; +@pagination-bg: @lightest; // superset-var +@pagination-border: @gray-light; // superset-var + +@pagination-hover-color: @link-hover-color; +@pagination-hover-bg: @gray-lighter; +@pagination-hover-border: @gray-light; // superset-var + +@pagination-active-color: @bs-gray-light; +@pagination-active-bg: @gray-bg; // superset-var +@pagination-active-border: @gray-light; // superset-var + +@pagination-disabled-color: @bs-gray-light; +@pagination-disabled-bg: @lightest; // superset-var +@pagination-disabled-border: @gray-light; // superset-var + +// == Pager +// +// ## + +@pager-bg: @pagination-bg; +@pager-border: @pagination-border; +@pager-border-radius: @border-radius-base; + +@pager-hover-bg: @pagination-hover-bg; + +@pager-active-bg: @pagination-active-bg; +@pager-active-color: @pagination-active-color; + +@pager-disabled-color: @bs-gray-light; + +// == Jumbotron +// +// ## + +@jumbotron-padding: 30px; +@jumbotron-color: inherit; +@jumbotron-bg: @gray-lighter; +@jumbotron-heading-color: inherit; +@jumbotron-font-size: ceil((@font-size-base * 1.5)); +@jumbotron-heading-font-size: ceil((@font-size-base * 4.5)); + +// == Form states and alerts +// +// ## Define colors for form feedback states and, by default, alerts. + +@state-success-text: @success-dark2; +@state-success-bg: @success-light2; +@state-success-border: @success-light2; + +@state-info-text: @info-dark2; +@state-info-bg: @info-light2; +@state-info-border: @info-light2; + +@state-warning-text: @warning-dark2; +@state-warning-bg: @warning-light2; +@state-warning-border: @warning-light2; + +@state-danger-text: @danger-dark2; +@state-danger-bg: @danger-light2; +@state-danger-border: @danger-light2; + +// == Tooltips +// +// ## + +// ** Tooltip max width +@tooltip-max-width: 200px; +// ** Tooltip text color +@tooltip-color: {{ theme.colors.grayscale.light1}}; // superset-var +// ** Tooltip background color +@tooltip-bg: {{theme.colorText}}; +@tooltip-opacity: 0.9; + +// ** Tooltip arrow width +@tooltip-arrow-width: 5px; +// ** Tooltip arrow color +@tooltip-arrow-color: @tooltip-bg; + +// == Popovers +// +// ## + +// ** Popover body background color +@popover-bg: @lightest; // superset-var +// ** Popover maximum width +@popover-max-width: 276px; +// ** Popover border color +@popover-border-color: fade(@darkest, @opacity-light); // superset-var +// ** Popover fallback border color +@popover-fallback-border-color: @gray-light; // superset-var + +// ** Popover title background color +@popover-title-bg: darken(@popover-bg, 3%); + +// ** Popover arrow width +@popover-arrow-width: 10px; +// ** Popover arrow color +@popover-arrow-color: @popover-bg; + +// ** Popover outer arrow width +@popover-arrow-outer-width: (@popover-arrow-width + 1); +// ** Popover outer arrow color +@popover-arrow-outer-color: fadein(@popover-border-color, 5%); +// ** Popover outer arrow fallback color +@popover-arrow-outer-fallback-color: darken( + @popover-fallback-border-color, + 20% +); + +// == Labels +// +// ## + +// ** Default label background color +@label-default-bg: @bs-gray-light; +// ** Primary label background color +@label-primary-bg: @brand-primary; +// ** Success label background color +@label-success-bg: @brand-success; +// ** Info label background color +@label-info-bg: @brand-info; +// ** Warning label background color +@label-warning-bg: darken(@brand-warning, 6%); +// ** Danger label background color +@label-danger-bg: @brand-danger; + +// ** Default label text color +@label-color: @lightest; // superset-var +// ** Default text color of a linked label +@label-link-hover-color: @lightest; // superset-var + +// == Modals +// +// ## + +// ** Padding applied to the modal body +@modal-inner-padding: 20px; + +// ** Padding applied to the modal title +@modal-title-padding: 15px; +// ** Modal title line-height +@modal-title-line-height: @line-height-base; + +// ** Background color of modal content area +@modal-content-bg: @lightest; // superset-var +// ** Modal content border color +@modal-content-border-color: transparent; +// ** Modal content border color **for IE8** +@modal-content-fallback-border-color: @gray; // superset-var + +// ** Modal backdrop background color +@modal-backdrop-bg: @darkest; // superset-var +// ** Modal backdrop opacity +@modal-backdrop-opacity: 0.5; +// ** Modal header border color +@modal-header-border-color: @gray-bg; // superset-var +// ** Modal footer border color +@modal-footer-border-color: @modal-header-border-color; + +@modal-lg: 900px; +@modal-md: 600px; +@modal-sm: 300px; + +// == Alerts +// +// ## Define alert colors, border radius, and padding. + +@alert-padding: 15px; +@alert-border-radius: @border-radius-base; +@alert-link-font-weight: @font-weight-bold; + +@alert-success-bg: @state-success-bg; +@alert-success-text: @state-success-text; +@alert-success-border: @state-success-border; + +@alert-info-bg: @state-info-bg; +@alert-info-text: @state-info-text; +@alert-info-border: @state-info-border; + +@alert-warning-bg: @state-warning-bg; +@alert-warning-text: @state-warning-text; +@alert-warning-border: @state-warning-border; + +@alert-danger-bg: @state-danger-bg; +@alert-danger-text: @state-danger-text; +@alert-danger-border: @state-danger-border; + +// == Progress bars +// +// ## + +// ** Background color of the whole progress component +@progress-bg: @gray-light; // superset-var +// ** Progress bar text color +@progress-bar-color: @lightest; // superset-var +// ** Variable for setting rounded corners on progress bar. +@progress-border-radius: @border-radius-base; + +// ** Default progress bar color +@progress-bar-bg: @brand-primary; +// ** Success progress bar color +@progress-bar-success-bg: @brand-success; +// ** Warning progress bar color +@progress-bar-warning-bg: @brand-warning; +// ** Danger progress bar color +@progress-bar-danger-bg: @brand-danger; +// ** Info progress bar color +@progress-bar-info-bg: @brand-info; + +// == List group +// +// ## + +// ** Background color on `.list-group-item` +@list-group-bg: @lightest; // superset-var +// ** `.list-group-item` border color +@list-group-border: @gray-light; // superset-var +// ** List group border radius +@list-group-border-radius: @border-radius-base; + +// ** Background color of single list items on hover +@list-group-hover-bg: @gray-bg; // superset-var +// ** Text color of active list items +@list-group-active-color: @component-active-color; +// ** Background color of active list items +@list-group-active-bg: @component-active-bg; +// ** Border color of active list elements +@list-group-active-border: @list-group-border; +// ** Text color for content within active list items +@list-group-active-text-color: lighten(@list-group-active-bg, 40%); + +// ** Text color of disabled list items +@list-group-disabled-color: @bs-gray-light; +// ** Background color of disabled list items +@list-group-disabled-bg: @gray-lighter; +// ** Text color for content within disabled list items +@list-group-disabled-text-color: @list-group-disabled-color; + +@list-group-link-color: #555; +@list-group-link-hover-color: @list-group-link-color; +@list-group-link-heading-color: @almost-black; // superset-var + +// == Panels +// +// ## + +@panel-bg: @lightest; // superset-var +@panel-body-padding: 15px; +@panel-heading-padding: 10px 15px; +@panel-footer-padding: @panel-heading-padding; +@panel-border-radius: @border-radius-base; + +// ** Border color for elements within panels +@panel-inner-border: @gray-light; // superset-var +@panel-footer-bg: @gray-bg; // superset-var + +@panel-default-text: @gray-dark; +@panel-default-border: transparent; +@panel-default-heading-bg: @lightest; // superset-var + +@panel-primary-text: @lightest; // superset-var +@panel-primary-border: transparent; +@panel-primary-heading-bg: @brand-primary; + +@panel-success-text: @state-success-text; +@panel-success-border: transparent; +@panel-success-heading-bg: @state-success-bg; + +@panel-info-text: @state-info-text; +@panel-info-border: transparent; +@panel-info-heading-bg: @state-info-bg; + +@panel-warning-text: @state-warning-text; +@panel-warning-border: transparent; +@panel-warning-heading-bg: @state-warning-bg; + +@panel-danger-text: @state-danger-text; +@panel-danger-border: transparent; +@panel-danger-heading-bg: @state-danger-bg; + +// == Thumbnails +// +// ## + +// ** Padding around the thumbnail image +@thumbnail-padding: 4px; +// ** Thumbnail background color +@thumbnail-bg: @body-bg; +// ** Thumbnail border color +@thumbnail-border: @gray-light; // superset-var +// ** Thumbnail border radius +@thumbnail-border-radius: @border-radius-base; + +// ** Custom text color for thumbnail captions +@thumbnail-caption-color: @text-color; +// ** Padding around the thumbnail caption +@thumbnail-caption-padding: 9px; + +// == Wells +// +// ## + +@well-bg: @gray-bg; // superset-var +@well-border: darken(@well-bg, 7%); + +// == Badges +// +// ## + +@badge-color: @lightest; // superset-var +// ** Linked badge text color on hover +@badge-link-hover-color: @lightest; // superset-var +@badge-bg: @brand-primary; + +// ** Badge text color in active nav link +@badge-active-color: @link-color; +// ** Badge background color in active nav link +@badge-active-bg: @lightest; // superset-var + +@badge-font-weight: @font-weight-bold; +@badge-line-height: 1; +@badge-border-radius: 10px; + +// == Breadcrumbs +// +// ## + +@breadcrumb-padding-vertical: 8px; +@breadcrumb-padding-horizontal: 15px; +// ** Breadcrumb background color +@breadcrumb-bg: @gray-bg; // superset-var +// ** Breadcrumb text color +@breadcrumb-color: @gray-light; // superset-var +// ** Text color of current page in the breadcrumb +@breadcrumb-active-color: @bs-gray-light; +// ** Textual separator for between breadcrumb elements +@breadcrumb-separator: '/'; + +// == Carousel +// +// ## + +@carousel-text-shadow: 0 1px 2px fade(@darkest, @opacity-light); // superset-var + +@carousel-control-color: @lightest; // superset-var +@carousel-control-width: 15%; +@carousel-control-opacity: 0.5; +@carousel-control-font-size: 20px; + +@carousel-indicator-active-bg: @lightest; // superset-var +@carousel-indicator-border-color: @lightest; // superset-var + +@carousel-caption-color: @lightest; // superset-var + +// == Close +// +// ## + +@close-font-weight: @font-weight-bold; +@close-color: @lightest; // superset-var +@close-text-shadow: 0 1px 0 @lightest; // superset-var + +// == Code +// +// ## + +@code-color: darken(@info, 10%); +@code-bg: @gray-bg; // superset-var + +@kbd-color: @lightest; // superset-var +@kbd-bg: @almost-black; // superset-var + +@pre-bg: @gray-bg; // superset-var +@pre-color: @gray-dark; +@pre-border-color: @gray-light; // superset-var +@pre-scrollable-max-height: 340px; + +// == Type +// +// ## + +// ** Horizontal offset for forms and lists. +@component-offset-horizontal: 180px; +// ** Text muted color +@text-muted: @bs-gray-light; +// ** Abbreviations and acronyms border color +@abbr-border-color: @bs-gray-light; +// ** Headings small color +@headings-small-color: @bs-gray-light; +// ** Blockquote small color +@blockquote-small-color: @bs-gray-light; +// ** Blockquote font size +@blockquote-font-size: (@font-size-base * 1.25); +// ** Blockquote border color +@blockquote-border-color: @gray-lighter; +// ** Page header border color +@page-header-border-color: @gray-lighter; +// ** Width of horizontal description list titles +@dl-horizontal-offset: @component-offset-horizontal; +// ** Point at which .dl-horizontal becomes horizontal +@dl-horizontal-breakpoint: @grid-float-breakpoint; +// ** Horizontal line color. +@hr-border: @gray-lighter; diff --git a/superset-frontend/src/assets/stylesheets/less/fonts.less b/superset-frontend/src/assets/stylesheets/less/fonts.less index 5fb41d832ae02..31eec2f516d94 100644 --- a/superset-frontend/src/assets/stylesheets/less/fonts.less +++ b/superset-frontend/src/assets/stylesheets/less/fonts.less @@ -27,7 +27,6 @@ @import '~@fontsource/inter/500.css'; @import '~@fontsource/inter/600.css'; -/******************************* Fira Code ********************************/ @import '~@fontsource/fira-code/400.css'; @import '~@fontsource/fira-code/500.css'; @import '~@fontsource/fira-code/600.css'; diff --git a/superset-frontend/src/assets/stylesheets/less/fonts.less.hbs b/superset-frontend/src/assets/stylesheets/less/fonts.less.hbs new file mode 100644 index 0000000000000..31eec2f516d94 --- /dev/null +++ b/superset-frontend/src/assets/stylesheets/less/fonts.less.hbs @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*************************************************************************/ +/* USAGE NOTES : Add font all licenses to LICENSE.text */ +/*************************************************************************/ + +/******************************* Inter UI ********************************/ +@import '~@fontsource/inter/200.css'; +@import '~@fontsource/inter/400.css'; +@import '~@fontsource/inter/500.css'; +@import '~@fontsource/inter/600.css'; + +@import '~@fontsource/fira-code/400.css'; +@import '~@fontsource/fira-code/500.css'; +@import '~@fontsource/fira-code/600.css'; diff --git a/superset-frontend/src/assets/stylesheets/less/index.less.hbs b/superset-frontend/src/assets/stylesheets/less/index.less.hbs new file mode 100644 index 0000000000000..fc91c477dbeb5 --- /dev/null +++ b/superset-frontend/src/assets/stylesheets/less/index.less.hbs @@ -0,0 +1,47 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +// Index .less, any imports here will be included in the final css build + +@import '~bootstrap/less/bootstrap.less'; +@import './fonts.less'; +@import './variables.less'; +@import './cosmo/bootswatch.less'; + +html, +body { + font-size: @font-size-base; + line-height: @line-height-base; +} + +body { + min-height: 100vh; + display: flex; + flex-direction: column; +} + +header { + flex: 0 1 auto; +} + +#app { + flex: 1 1 auto; + position: relative; + display: flex; + flex-direction: column; +} diff --git a/superset-frontend/src/assets/stylesheets/less/variables.less b/superset-frontend/src/assets/stylesheets/less/variables.less index fe9b8987fd041..a0176905994b5 100644 --- a/superset-frontend/src/assets/stylesheets/less/variables.less +++ b/superset-frontend/src/assets/stylesheets/less/variables.less @@ -19,71 +19,73 @@ /************************************************************************/ /* COLORS */ -/* Please attempt to use and standardize on these colors, */ -/* rather than including specific color values in */ -/* component styles. This will allow us to more easily adjust theming */ /************************************************************************/ -@primary-color: #20a7c9; +@primary-color: #1e91ae; @indicator-color: @primary-color; -@brand-primary-dark1: #1a85a0; -@brand-primary-dark2: #156378; -@brand-primary-light1: #79cade; -@brand-primary-light2: #a5dae9; -@brand-primary-light3: #d2edf4; -@brand-primary-light4: #e9f6f9; -@brand-primary-light5: #f3f8fa; - -@brand-secondary: #444e7c; -@brand-secondary-dark1: #363e63; -@brand-secondary-dark2: #282e4a; -@brand-secondary-dark3: #1b1f31; -@brand-secondary-light1: #8e94b0; -@brand-secondary-light2: #b4b8ca; -@brand-secondary-light3: #d9dbe4; -@brand-secondary-light4: #eceef2; -@brand-secondary-light5: #f5f5f8; - -@almost-black: #263238; -@gray-dark: #484848; -@gray-light: #e0e0e0; -@gray-light5: #666666; -@gray: #879399; -@gray-bg: #f7f7f7; -@gray-heading: #a3a3a3; -@menu-hover: #f2f3f5; -@lightest: #ffffff; -@darkest: #000000; +@brand-primary-dark1: #1e91ae; +@brand-primary-dark2: #4ba7be; +@brand-primary-light1: #18748b; +@brand-primary-light2: #115060; +@brand-primary-light3: #092c34; +@brand-primary-light4: #030f11; +@brand-primary-light5: #020709; + +@brand-secondary: #1e91ae; +@brand-secondary-dark1: #1e91ae; +@brand-secondary-dark2: #4ba7be; +@brand-secondary-dark3: #78bdce; +@brand-secondary-light1: #18748b; +@brand-secondary-light2: #115060; +@brand-secondary-light3: #092c34; +@brand-secondary-light4: #030f11; +@brand-secondary-light5: #020709; + +// TODO line up with theme +@almost-black: #e0e0e0; +@gray-dark: #a3a3a3; +@gray-light: #0a0a0a; +@gray-light5: #050505; +@gray: #1e91ae; +@gray-bg: #0a0a0a; +@gray-heading: rgba(255, 255, 255, 0.85); +@menu-hover: rgba(255, 255, 255, 0.85); +@lightest: #141414; +@darkest: rgba(255, 255, 255, 0.85); + +@body-bg: #141414; /**************************** text-specific *****************************/ -@link: #1985a0; -@link-hover: darken(@link, @colorstop-one); +@text-color: #fff; +@heading-color: #fff; +@link: #1e91ae; +@link-hover: #4ba7be; /***************************** status colors ****************************/ -@info: #66bcfe; -@info-dark1: #4d8cbe; -@info-dark2: #315e7e; -@info-light1: #b3defe; -@info-light2: #eff8fe; - -@danger: #e04355; -@danger-dark1: #a7323f; -@danger-dark2: #6f212a; -@danger-light1: #efa1aa; -@danger-light2: #faedee; - -@success: #5ac189; -@success-dark1: #439066; -@success-dark2: #2b6144; -@success-light1: #ace1c4; -@success-light2: #eef8f3; - -@warning: #fcc700; -@warning-dark1: #bc9501; -@warning-dark2: #7d6300; -@warning-light1: #fde380; -@warning-light2: #fef9e6; +@info: #5aa3db; +@info-dark1: #6bacdf; +@info-dark2: #7bb5e2; +@info-light1: #4882af; +@info-light2: #325a78; + +@danger: #c13c4b; +@danger-dark1: #c7505d; +@danger-dark2: #cd636f; +@danger-light1: #9a303c; +@danger-light2: #6a2129; + +@success: #50a777; +@success-dark1: #62b085; +@success-dark2: #73b992; +@success-light1: #40865f; +@success-light2: #2c5c41; + +@warning: #d9ac03; +@warning-dark1: #ddb41c; +@warning-dark2: #e1bd35; +@warning-light1: #ae8a02; +@warning-light2: #775f02; /* general component effects */ @shadow-highlight: @primary-color; @@ -141,21 +143,18 @@ /* Commonly used font weights, line heights, etc. These should be the */ /* core values used to build more complex styles for headers, etc. */ /************************************************************************/ +@font-size-base: 14px; // Base `rem` units on this, as needed. -// *************************** Weights ********************************** -@font-weight-light: 200; +@font-weight-light: 300; @font-weight-normal: 400; @font-weight-bold: 600; -// ***************************** Font Sizes ***************************** -@font-size-base: 14px; // Base `rem` units on this, as needed. - -@font-size-xxs: 9px; -@font-size-xs: 10px; +@font-size-xxs: 7px; +@font-size-xs: 8px; @font-size-s: 12px; -@font-size-m: @font-size-base; +@font-size-m: 14px; @font-size-l: 16px; -@font-size-xl: 21px; +@font-size-xl: 20px; @font-size-xxl: 28px; // **************************** Line Heights **************************** @@ -184,16 +183,16 @@ } // ****************************** Families ****************************** + @font-family-sans-serif: 'Inter', Helvetica, Arial; -@font-family-serif: Georgia, 'Times New Roman', Times, serif; @font-family-monospace: 'Fira Code', 'Courier New', monospace; @font-family-base: @font-family-sans-serif; +@line-height-tight: 1; /************************************************************************/ /* TRANSITIONS */ -/* Timing and easings presets used in CSS transitions */ /************************************************************************/ -@timing-normal: 0.3s; +@timing-normal: 0.2s; /************************************************************************/ /* BORDER RADII */ diff --git a/superset-frontend/src/assets/stylesheets/less/variables.less.hbs b/superset-frontend/src/assets/stylesheets/less/variables.less.hbs new file mode 100644 index 0000000000000..e6f7d0036a8d9 --- /dev/null +++ b/superset-frontend/src/assets/stylesheets/less/variables.less.hbs @@ -0,0 +1,211 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/************************************************************************/ +/* COLORS */ +/************************************************************************/ + +@primary-color: {{theme.colorPrimary}}; +@indicator-color: @primary-color; + +@brand-primary-dark1: {{theme.colorPrimaryText}}; +@brand-primary-dark2: {{theme.colors.primary.dark2}}; +@brand-primary-light1: {{theme.colors.primary.light1}}; +@brand-primary-light2: {{theme.colors.primary.light2}}; +@brand-primary-light3: {{theme.colors.primary.light3}}; +@brand-primary-light4: {{theme.colors.primary.light4}}; +@brand-primary-light5: {{theme.colors.primary.light5}}; + +@brand-secondary: {{theme.colorPrimary}}; +@brand-secondary-dark1: {{theme.colorPrimaryText}}; +@brand-secondary-dark2: {{theme.colors.primary.dark2}}; +@brand-secondary-dark3: {{theme.colors.primary.dark3}}; +@brand-secondary-light1: {{theme.colors.primary.light1}}; +@brand-secondary-light2: {{theme.colors.primary.light2}}; +@brand-secondary-light3: {{theme.colors.primary.light3}}; +@brand-secondary-light4: {{theme.colors.primary.light4}}; +@brand-secondary-light5: {{theme.colors.primary.light5}}; + +// TODO line up with theme +@almost-black: {{theme.colors.grayscale.dark5}}; +@gray-dark: {{theme.colors.grayscale.dark3}}; +@gray-light: {{theme.colors.grayscale.light4}}; +@gray-light5: {{theme.colors.grayscale.light5}}; +@gray: {{theme.colorPrimary}}; +@gray-bg: {{theme.colors.grayscale.light4}}; +@gray-heading: {{theme.colorText}}; +@menu-hover: {{theme.colorText}}; +@lightest: {{theme.colorBgContainer}}; +@darkest: {{theme.colorText}}; + +@body-bg: {{theme.colorBgContainer}}; + +/**************************** text-specific *****************************/ +@text-color: {{theme.colorTextBase}}; +@heading-color: {{theme.colorTextBase}}; +@link: {{theme.colorPrimaryText}}; +@link-hover: {{theme.colors.primary.dark2}}; + +/***************************** status colors ****************************/ +@info: {{theme.colorInfo}}; +@info-dark1: {{theme.colors.info.dark1}}; +@info-dark2: {{theme.colors.info.dark2}}; +@info-light1: {{theme.colors.info.light1}}; +@info-light2: {{theme.colors.info.light2}}; + +@danger: {{theme.colorError}}; +@danger-dark1: {{theme.colors.error.dark1}}; +@danger-dark2: {{theme.colors.error.dark2}}; +@danger-light1: {{theme.colors.error.light1}}; +@danger-light2: {{theme.colors.error.light2}}; + +@success: {{theme.colorSuccess}}; +@success-dark1: {{theme.colors.success.dark1}}; +@success-dark2: {{theme.colors.success.dark2}}; +@success-light1: {{theme.colors.success.light1}}; +@success-light2: {{theme.colors.success.light2}}; + +@warning: {{theme.colorWarning}}; +@warning-dark1: {{theme.colors.warning.dark1}}; +@warning-dark2: {{theme.colors.warning.dark2}}; +@warning-light1: {{theme.colors.warning.light1}}; +@warning-light2: {{theme.colors.warning.light2}}; + +/* general component effects */ +@shadow-highlight: @primary-color; + +/************************************************************************/ +/* OPACITIES */ +/* Used in LESS filters, e.g. fade(@someColorVar, @someOpacityBelow) */ +/************************************************************************/ +@opacity-light: 10%; +@opacity-medium-light: 35%; +@opacity-medium-heavy: 60%; +@opacity-heavy: 80%; + +/************************************************************************/ +/* SHADES & TINTS */ +/* Used in LESS filters for shadint/tinting, */ +/* e.g. shade(@someColorVar, @colorstop-one) to darken */ +/* or tint(@someColorVar, @colorstop-one) to lighten */ +/************************************************************************/ +@colorstop-one: 20%; +@colorstop-two: 40%; +@colorstop-three: 60%; +@colorstop-four: 80%; + +/************************************************************************/ +/* LAYOUT */ +/* Widths and heights of things, that might be referred to often */ +/************************************************************************/ + +/* builder component pane */ +@builder-pane-width: 374px; + +/************************************************************************/ +/* Z-INDEX */ +/* Think of the site as "layers" rather than an arms race of numbers */ +/* Keep these to a minimum */ +/* Label semantic "layers" and add comments for usage notes */ +/* Use double dash modifiers to step up/down from a base layer */ +/* e.g. z-whatever--modifier */ +/************************************************************************/ + +/************************ toast messages, popovers **********************/ +@z-index-max: 3000; + +/***** filters, dashboard editor widgets, Explore reloading overlay *****/ +@z-index-dropdown: @z-index-above-dashboard-charts + 1; +@z-index-above-dashboard-charts: 10; + +/******************************** charts ********************************/ +@z-index-chart--dragging: @z-index-chart + 1; +@z-index-chart: 1; + +/************************************************************************/ +/* TYPOGRAPHY */ +/* Commonly used font weights, line heights, etc. These should be the */ +/* core values used to build more complex styles for headers, etc. */ +/************************************************************************/ +@font-size-base: 14px; // Base `rem` units on this, as needed. + +@font-weight-light: {{theme.fontWeightLight}}; +@font-weight-normal: {{theme.fontWeightNormal}}; +@font-weight-bold: {{theme.fontWeightStrong}}; + +@font-size-xxs: 7px; +@font-size-xs: 8px; +@font-size-s: {{theme.fontSizeSM}}px; +@font-size-m: {{theme.fontSize}}px; +@font-size-l: {{theme.fontSizeLG}}px; +@font-size-xl: {{theme.fontSizeXL}}px; +@font-size-xxl: 28px; + +// **************************** Line Heights **************************** +@line-height-base: 1.4; +// Ranged Sizes +@line-height-tight: 1; +@line-height-normal: @line-height-base; +@line-height-loose: 2; + +// ****************************** Features ******************************* +@use-ligatures: false; + +// setting up OTF settings based on @use-ligatures: +.set-otf-options(@use-ligatures); + +.set-otf-options(true) { + @font-feature-settings: + 'liga' on, + 'calt' on; +} + +.set-otf-options(false) { + @font-feature-settings: + 'liga' off, + 'calt' off; +} + +// ****************************** Families ****************************** + +@font-family-sans-serif: {{theme.fontFamily}}; +@font-family-monospace: {{theme.fontFamilyCode}}; +@font-family-base: @font-family-sans-serif; +@line-height-tight: 1; + +/************************************************************************/ +/* TRANSITIONS */ +/************************************************************************/ +@timing-normal: {{theme.motionDurationMid}}; + +/************************************************************************/ +/* BORDER RADII */ +/* Standard border-radius settings */ +/************************************************************************/ +@border-radius-normal: 4px; +@border-radius-large: (@border-radius-normal * 2); + +/************************************************************************/ +/* BOOTSTRAP/BOOTSWATCH/COSMO */ +/* These are the legacy Cosmo theme overrides to Bootswatch's */ +/* overrides to Bootstrap. We should consolidate/deprecate these */ +/* in favor of custom/reusable CSS wherever possible */ +/************************************************************************/ + +@import '../less/cosmo/variables.less'; diff --git a/superset-frontend/src/assets/stylesheets/reactable-pagination.less.hbs b/superset-frontend/src/assets/stylesheets/reactable-pagination.less.hbs new file mode 100644 index 0000000000000..9b48d2143ab8f --- /dev/null +++ b/superset-frontend/src/assets/stylesheets/reactable-pagination.less.hbs @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +@import './less/variables.less'; + +.reactable-pagination td { + padding: 15px 0 0 0 !important; +} + +.reactable-pagination a:focus { + text-decoration: none; + color: @gray-dark; + outline: 1; +} + +.reactable-page-button, +.reactable-next-page, +.reactable-previous-page { + background: @lightest; + border-radius: @border-radius-normal; + border: 1px solid @gray-light; + color: @gray-dark; + display: inline-block; + font-size: @font-size-s; + margin-right: 5px; + padding: 5px 10px; + text-align: center; + text-decoration: none; + vertical-align: middle; + white-space: nowrap; + + &:hover { + background-color: @gray-bg; + border-color: @gray; + color: @gray-dark; + text-decoration: none; + } +} + +.reactable-current-page { + border: 1px solid @gray-light; + color: @gray-dark; + font-weight: @font-weight-bold; + pointer-events: none; + opacity: 0.65; +} diff --git a/superset-frontend/src/assets/stylesheets/superset.less.hbs b/superset-frontend/src/assets/stylesheets/superset.less.hbs new file mode 100644 index 0000000000000..7bf8c27fff60e --- /dev/null +++ b/superset-frontend/src/assets/stylesheets/superset.less.hbs @@ -0,0 +1,552 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +@import './less/index.less'; +@import './less/variables.less'; +@import './less/index.less'; + +@datasource-sql-expression-width: 315px; + +span, +div, +i { + &:focus { + outline: none; + } +} + +.alert.alert-danger > .debugger { + color: @danger; +} + +.no-wrap { + white-space: nowrap; +} + +input.form-control { + background-color: @lightest; +} + +.disabledButton { + pointer-events: none; +} + +.col-left-fixed { + width: 350px; + position: absolute; + float: left; +} + +.col-offset { + margin-left: 365px; +} + +.slice_description { + padding: 8px; + margin: 5px 0; + border: 1px solid @gray-light; + background-color: @gray-bg; + border-radius: @border-radius-large; + font-size: @font-size-s; +} + +.slice_info { + cursor: pointer; +} + +.padded { + padding: 10px; +} + +.intable-longtext { + max-height: 200px; + overflow: auto; +} + +.container-fluid { + text-align: left; + padding-left: 16px; + padding-right: 16px; +} + +input[type='checkbox'] { + display: inline-block; + width: 16px; + height: 16px; +} + +.widget-is-cached { + display: none; +} + +.header span.label { + margin-left: 5px; + margin-right: 5px; +} + +.notbtn { + cursor: default; + box-shadow: none; + border: 1px solid @gray; +} + +hr { + margin-top: 15px; + margin-bottom: 15px; +} + +span.title-block { + background-color: @gray-bg; + border-radius: @border-radius-large; + padding: 6px 12px; + margin: 0px 10px; + font-size: @font-size-xl; +} + +.nvtooltip { + table td { + font-size: @font-size-s !important; + } +} + +div.navbar { + .dropdown-menu .fineprint { + line-height: 1.5rem; + padding: 10px 20px 5px 20px; + color: @gray-light; + font-size: @font-size-m; + + div { + white-space: nowrap; + } + } +} + +.datasource { + form { + div.form-control, + input.form-control { + margin-bottom: 5px !important; + } + } + + .tooltip-inner { + max-width: 350px; + } +} + +img.viz-thumb-option { + width: 100px; + border: 1px solid @gray; + margin-right: 5px; + border-radius: @border-radius-large; +} + +.select2-drop.bigdrop .select2-results { + max-height: 700px; +} + +#is_cached { + display: none; +} + +.slice_container.faded { + opacity: 0.2; +} + +.navbar .alert { + padding: 5px 10px; + margin-top: 8px; + margin-bottom: 0; +} + +.table-condensed { + font-size: @font-size-s; +} + +.table-condensed input[type='checkbox'] { + float: left; +} + +table.table-no-hover tr:hover { + background-color: initial; +} + +.editable-title input { + outline: none; + background: transparent; + border: none; + box-shadow: none; + padding: 0; + cursor: initial; +} + +.editable-title textarea { + outline: none; + background: transparent; + box-shadow: none; + cursor: initial; + border: 1px solid @gray; + border-radius: @border-radius-normal; +} + +.editable-title input[type='text'] { + border: 1px solid @gray; + border-radius: @border-radius-normal; + padding: 2px; +} + +.editable-title.datasource-sql-expression { + font-feature-settings: @font-feature-settings; + font-family: @font-family-monospace; + display: inline-block; + min-width: @datasource-sql-expression-width; + width: 100%; +} + +.editable-title.datasource-sql-expression input { + width: 95%; + padding-bottom: 5px; +} + +.editable-title.datasource-sql-expression textarea { + min-height: 100px; + width: 95%; +} + +.editable-title input[type='button'] { + border-color: transparent; + background: transparent; + font-size: inherit; + white-space: normal; + text-align: left; + cursor: initial; +} + +.editable-title.editable-title--editable input[type='button'] { + cursor: pointer; +} + +.editable-title.editable-title--editing input[type='button'] { + cursor: text; +} + +.anchor-link-container { + position: absolute; + + .btn.btn-sm, + .btn.btn-sm:active { + border: none; + padding-top: 0; + padding-bottom: 0; + background: none; + box-shadow: none; + } + + .fa.fa-link { + position: relative; + top: 2px; + right: 0; + visibility: hidden; + font-size: @font-size-s; + text-align: center; + vertical-align: middle; + } +} + +.dashboard-component.dashboard-component-header .anchor-link-container { + .fa.fa-link { + font-size: @font-size-l; + } +} + +.dashboard-component.dashboard-component-header:hover { + .anchor-link-container { + cursor: pointer; + + .fa.fa-link { + visibility: visible; + } + } +} + +.m-r-5 { + margin-right: 5px; +} + +.m-r-3 { + margin-right: 3px; +} + +.m-t-4 { + margin-top: 4px; +} + +.m-t-5 { + margin-top: 5px; +} + +.m-t-10 { + margin-top: 10px; +} + +.m-t-20 { + margin-top: 20px; +} + +.m-b-10 { + margin-bottom: 10px; +} + +.m-l-2 { + margin-left: 2px; +} + +.m-l-4 { + margin-left: 4px; +} + +.m-l-5 { + margin-left: 5px; +} + +.m-l-10 { + margin-left: 10px; +} + +.m-l-25 { + margin-left: 25px; +} + +.p-l-0 { + padding-left: 0; +} + +.p-t-8 { + padding-top: 8; +} + +.p-r-2 { + padding-right: 2; +} + +.list-container { + position: relative; +} + +.list-search-container { + position: relative; +} + +.list-search-container .dropdown-toggle { + position: absolute; + top: -43px; + right: 25px; + border: 0; + padding: 0 18px; +} + +.list-search-container .fa-filter { + position: relative; + left: -8px; +} + +.list-search-container .dropdown-menu { + top: -19px; + right: 0; + left: auto; + float: none; +} + +.list-container .pagination-container { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + align-items: center; + padding-bottom: 20px; +} + +.list-container .pagination-container .pagination { + margin: 0 15px; +} + +.list-container .pagination-container strong { + margin-right: 5px; +} + +.list-container .list-add-action { + position: absolute; + top: -30px; + right: 15px; +} + +.list-container .form-actions-container { + padding: 0 0 20px 10px; + display: inline; +} + +.form-actions-container button { + display: flex; + + .caret { + margin: 0 8px; + } +} + +.list-container .filter-action { + margin: 10px 10px 0 10px; + padding-bottom: 15px; +} + +.list-add-action .btn.btn-sm { + padding: 6px 6px; + font-size: @font-size-xs; + line-height: 2px; + border-radius: 50%; + box-shadow: 2px 2px 4px -1px fade(@darkest, @opacity-light); + i { + width: 10px; + } +} + +iframe { + border: none; + width: 100%; +} + +.text-transparent { + color: transparent; +} + +.pointer { + cursor: pointer; +} + +.popover { + max-width: 500px; +} + +.float-left { + float: left; +} + +.float-right { + float: right; +} + +g.annotation-container { + line { + stroke: @brand-primary; + } + + rect.annotation { + stroke: @brand-primary; + fill-opacity: 0.1; + stroke-width: 1; + } +} + +.stroke-primary { + stroke: @brand-primary; +} + +.reactable-header-sortable { + position: relative; + padding-right: 40px; + + &::after { + font: normal normal normal 14px/1 FontAwesome; + content: '\f0dc'; + margin-left: 10px; + color: @brand-primary; + } +} + +.reactable-header-sort-asc::after { + content: '\f0de'; + color: @brand-primary; +} + +.reactable-header-sort-desc::after { + content: '\f0dd'; + color: @brand-primary; +} + +tr.reactable-column-header th.reactable-header-sortable { + padding-right: 17px; +} + +.align-right { + text-align: right; +} + +td.filtered { + background-color: lighten(desaturate(@brand-primary, 50%), 50%); +} + +.table-name { + font-size: @font-size-l; +} +.select2-container-multi { + width: 100% !important; +} + +/* +Hides the logo while loading the page. +Emotion styles will take care of the correct styling +*/ +.navbar-brand { + display: none; +} + +// Making native radio buttons use brand color +input[type='radio']:after { + width: 15px; + height: 15px; + border-radius: 15px; + top: -2px; + left: -1px; + position: relative; + background-color: #fff; + content: ''; + display: inline-block; + visibility: visible; + border: 2px solid @gray; +} + +input[type='radio']:checked:after { + width: 15px; + height: 15px; + border-radius: 15px; + top: -2px; + left: -1px; + position: relative; + background-color: #fff; + content: ''; + display: inline-block; + visibility: visible; + border: 5px solid @brand-primary; +} +hr { + border-top: 1px solid @gray-light; +} +.ace_gutter-cell.ace_error { + background-image: url('../images/icons/error_solid_small_red.svg') !important; + background-position: -2px center !important; +} diff --git a/superset-frontend/src/components/Alert/Alert.test.tsx b/superset-frontend/src/components/Alert/Alert.test.tsx deleted file mode 100644 index f7cb342a75d54..0000000000000 --- a/superset-frontend/src/components/Alert/Alert.test.tsx +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import { render, screen, waitFor } from 'spec/helpers/testing-library'; -import userEvent from '@testing-library/user-event'; -import Alert, { AlertProps } from 'src/components/Alert'; - -type AlertType = Pick; -type AlertTypeValue = AlertType[keyof AlertType]; - -test('renders with default props', async () => { - render(); - - expect(screen.getByRole('alert')).toHaveTextContent('Message'); - expect(screen.getByRole('img', { name: 'info-circle' })).toBeInTheDocument(); -}); - -test('renders message for each alert type', () => { - const types: AlertTypeValue[] = ['info', 'error', 'warning', 'success']; - - types.forEach(type => { - const { rerender } = render(); - expect(screen.getByText('Test message')).toBeInTheDocument(); - rerender(<>); // Clean up between renders - }); -}); - -test('renders without close button', async () => { - render(); - await waitFor(() => { - expect(screen.queryByLabelText('close icon')).not.toBeInTheDocument(); - }); -}); - -test('disappear when closed', async () => { - render(); - userEvent.click(screen.getByRole('img', { name: 'close' })); - await waitFor(() => { - expect(screen.queryByRole('alert')).not.toBeInTheDocument(); - }); -}); - -test('renders without icon', async () => { - render(); - await waitFor(() => { - expect(screen.queryByLabelText('info icon')).not.toBeInTheDocument(); - }); -}); - -test('renders message and description', async () => { - render(); - const alert = await screen.findByRole('alert'); - expect(alert).toHaveTextContent('Message'); - expect(alert).toHaveTextContent('Description'); -}); - -test('calls onClose callback when closed', () => { - const onCloseMock = jest.fn(); - render(); - userEvent.click(screen.getByRole('img', { name: 'close' })); - expect(onCloseMock).toHaveBeenCalledTimes(1); -}); diff --git a/superset-frontend/src/components/AntdThemeProvider/index.tsx b/superset-frontend/src/components/AntdThemeProvider/index.tsx index 28ddcabf34ad1..beff6d0d41fe3 100644 --- a/superset-frontend/src/components/AntdThemeProvider/index.tsx +++ b/superset-frontend/src/components/AntdThemeProvider/index.tsx @@ -18,18 +18,12 @@ */ import { ConfigProvider, type ConfigProviderProps } from 'antd-v5'; -import { getTheme, ThemeType } from 'src/theme/index'; export const AntdThemeProvider = ({ - theme, children, ...rest }: ConfigProviderProps) => ( - + {children} ); diff --git a/superset-frontend/src/components/AsyncAceEditor/index.tsx b/superset-frontend/src/components/AsyncAceEditor/index.tsx index c656f4008674b..75a48624b62ab 100644 --- a/superset-frontend/src/components/AsyncAceEditor/index.tsx +++ b/superset-frontend/src/components/AsyncAceEditor/index.tsx @@ -192,7 +192,7 @@ export default function AsyncAceEditor( .ant-tag { diff --git a/superset-frontend/src/components/Badge/index.tsx b/superset-frontend/src/components/Badge/index.tsx index 463884e5075bf..171229f601040 100644 --- a/superset-frontend/src/components/Badge/index.tsx +++ b/superset-frontend/src/components/Badge/index.tsx @@ -27,9 +27,7 @@ const Badge = styled((props: AntdBadgeProps) => )` & > sup, & > sup.antd5-badge-count { ${ - count !== undefined - ? `background: ${color || theme.colors.primary.base};` - : '' + count !== undefined ? `background: ${color || theme.colorPrimary};` : '' } } `} diff --git a/superset-frontend/src/components/Button/index.tsx b/superset-frontend/src/components/Button/index.tsx index c38fbc15cab73..6046225b4c45e 100644 --- a/superset-frontend/src/components/Button/index.tsx +++ b/superset-frontend/src/components/Button/index.tsx @@ -91,8 +91,9 @@ export default function Button(props: ButtonProps) { } = props; const theme = useTheme(); - const { colors, transitionTiming, borderRadius, typography } = theme; - const { primary, grayscale, success, warning } = colors; + const { transitionTiming, borderRadius, fontSizeSM, fontWeightStrong } = + theme; + const { primary, grayscale, warning } = theme.colors; let height = 32; let padding = 18; @@ -112,7 +113,7 @@ export default function Button(props: ButtonProps) { let colorHover; let borderWidth = 0; let borderStyle = 'none'; - let borderColor; + let borderColor = theme.colorBorder; let borderColorHover; let borderColorDisabled = 'transparent'; @@ -130,14 +131,14 @@ export default function Button(props: ButtonProps) { colorHover = color; } else if (buttonStyle === 'warning') { backgroundColor = warning.base; - backgroundColorHover = mix(0.1, grayscale.dark2, warning.base); - backgroundColorActive = mix(0.2, grayscale.dark2, warning.base); + backgroundColorHover = mix(0.1, grayscale.dark2, theme.colorWarningActive); + backgroundColorActive = mix(0.2, grayscale.dark2, theme.colorWarningActive); color = grayscale.light5; colorHover = color; } else if (buttonStyle === 'success') { - backgroundColor = success.base; - backgroundColorHover = mix(0.1, grayscale.light5, success.base); - backgroundColorActive = mix(0.2, grayscale.dark2, success.base); + backgroundColor = theme.colorSuccessText; + backgroundColorHover = mix(0.1, grayscale.light5, theme.colorSuccessActive); + backgroundColorActive = mix(0.2, grayscale.dark2, theme.colorSuccessActive); color = grayscale.light5; colorHover = color; } else if (buttonStyle === 'link') { @@ -156,7 +157,7 @@ export default function Button(props: ButtonProps) { renderedChildren = Children.toArray(children); } const firstChildMargin = - showMarginRight && renderedChildren.length > 1 ? theme.gridUnit * 2 : 0; + showMarginRight && renderedChildren.length > 1 ? theme.sizeUnit * 2 : 0; const effectiveButtonStyle: ButtonStyle = buttonStyle ?? 'default'; @@ -179,13 +180,13 @@ export default function Button(props: ButtonProps) { alignItems: 'center', justifyContent: 'center', lineHeight: 1.5715, - fontSize: typography.sizes.s, - fontWeight: typography.weights.bold, + fontSize: fontSizeSM, + fontWeight: fontWeightStrong, height, padding: `0px ${padding}px`, transition: `all ${transitionTiming}s`, - minWidth: cta ? theme.gridUnit * 36 : undefined, - minHeight: cta ? theme.gridUnit * 8 : undefined, + minWidth: cta ? theme.sizeUnit * 36 : undefined, + minHeight: cta ? theme.sizeUnit * 8 : undefined, boxShadow: 'none', borderWidth, borderStyle, @@ -223,7 +224,7 @@ export default function Button(props: ButtonProps) { }, marginLeft: 0, '& + .superset-button': { - marginLeft: theme.gridUnit * 2, + marginLeft: theme.sizeUnit * 2, }, '& > span > :first-of-type': { marginRight: firstChildMargin, @@ -245,7 +246,7 @@ export default function Button(props: ButtonProps) { css={{ cursor: 'not-allowed', '& > .superset-button': { - marginLeft: theme.gridUnit * 2, + marginLeft: theme.sizeUnit * 2, }, }} > diff --git a/superset-frontend/src/components/Card/index.tsx b/superset-frontend/src/components/Card/index.tsx index 855f50c273f51..f15530770d768 100644 --- a/superset-frontend/src/components/Card/index.tsx +++ b/superset-frontend/src/components/Card/index.tsx @@ -28,10 +28,8 @@ const Card = ({ padded, ...props }: CardProps) => ( ({ - // 'border-radius': `${theme.gridUnit}px`, - border: `1px solid ${theme.colors.grayscale.light2}`, '.antd5-card-body': { - padding: padded ? theme.gridUnit * 4 : theme.gridUnit, + padding: padded ? theme.sizeUnit * 4 : theme.sizeUnit, }, })} /> diff --git a/superset-frontend/src/components/CertifiedBadge/index.tsx b/superset-frontend/src/components/CertifiedBadge/index.tsx index 65179d046eab2..5dc5ded10f35b 100644 --- a/superset-frontend/src/components/CertifiedBadge/index.tsx +++ b/superset-frontend/src/components/CertifiedBadge/index.tsx @@ -47,7 +47,7 @@ function CertifiedBadge({ } > - + ); } diff --git a/superset-frontend/src/components/Chart/Chart.tsx b/superset-frontend/src/components/Chart/Chart.tsx index 0389ebd3094d9..50eff09b13dd4 100644 --- a/superset-frontend/src/components/Chart/Chart.tsx +++ b/superset-frontend/src/components/Chart/Chart.tsx @@ -137,7 +137,7 @@ const Styles = styled.div<{ height: number; width?: number }>` .chart-tooltip { opacity: 0.75; - font-size: ${({ theme }) => theme.typography.sizes.s}px; + font-size: ${({ theme }) => theme.fontSizeSM}px; } .slice_container { @@ -152,7 +152,7 @@ const Styles = styled.div<{ height: number; width?: number }>` } .alert { - margin: ${({ theme }) => theme.gridUnit * 2}px; + margin: ${({ theme }) => theme.sizeUnit * 2}px; } } `; @@ -168,7 +168,7 @@ const LoadingDiv = styled.div` const MessageSpan = styled.span` display: block; text-align: center; - margin: ${({ theme }) => theme.gridUnit * 4}px auto; + margin: ${({ theme }) => theme.sizeUnit * 4}px auto; width: fit-content; color: ${({ theme }) => theme.colors.grayscale.base}; `; diff --git a/superset-frontend/src/components/Chart/ChartRenderer.jsx b/superset-frontend/src/components/Chart/ChartRenderer.jsx index dd456b0db43c3..712b6f498a877 100644 --- a/superset-frontend/src/components/Chart/ChartRenderer.jsx +++ b/superset-frontend/src/components/Chart/ChartRenderer.jsx @@ -317,7 +317,7 @@ class ChartRenderer extends Component { ); } else { noResultsComponent = ( - + ); } diff --git a/superset-frontend/src/components/Chart/DisabledMenuItemTooltip.tsx b/superset-frontend/src/components/Chart/DisabledMenuItemTooltip.tsx index 33eb662114520..f66580d742941 100644 --- a/superset-frontend/src/components/Chart/DisabledMenuItemTooltip.tsx +++ b/superset-frontend/src/components/Chart/DisabledMenuItemTooltip.tsx @@ -33,8 +33,8 @@ export const MenuItemTooltip = ({ css` - color: ${color || theme.colors.text.label}; - margin-left: ${theme.gridUnit * 2}px; + color: ${color || theme.colorTextLabel}; + margin-left: ${theme.sizeUnit * 2}px; &.anticon { font-size: unset; .anticon { diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx index 47666db7802f0..4e400bcfc5cae 100644 --- a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx @@ -298,12 +298,7 @@ export const DrillByMenuItems = ({ {showSearch && ( - } + prefix={} onChange={e => { e.stopPropagation(); handleInput(e.target.value); @@ -317,7 +312,7 @@ export const DrillByMenuItems = ({ css={css` width: auto; max-width: 100%; - margin: ${theme.gridUnit * 2}px ${theme.gridUnit * 3}px; + margin: ${theme.sizeUnit * 2}px ${theme.sizeUnit * 3}px; box-shadow: none; `} value={searchInput} @@ -326,7 +321,7 @@ export const DrillByMenuItems = ({ {isLoadingColumns ? (
diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx index 987003f16d250..55f5b5b2f879b 100644 --- a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx @@ -136,7 +136,7 @@ const ModalFooter = ({ formData, closeModal }: ModalFooterProps) => { onClick={closeModal} data-test="close-drill-by-modal" css={css` - margin-left: ${theme.gridUnit * 2}px; + margin-left: ${theme.sizeUnit * 2}px; `} > {t('Close')} @@ -439,8 +439,8 @@ export default function DrillByModal({ responsive resizable resizableConfig={{ - minHeight: theme.gridUnit * 128, - minWidth: theme.gridUnit * 128, + minHeight: theme.sizeUnit * 128, + minWidth: theme.sizeUnit * 128, defaultSize: { width: 'auto', height: '80vh', diff --git a/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx b/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx index bd2729633e645..3dcb613b4e9dd 100644 --- a/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx @@ -31,7 +31,7 @@ export const useDisplayModeToggle = () => { () => (
css` - margin-bottom: ${theme.gridUnit * 6}px; + margin-bottom: ${theme.sizeUnit * 6}px; .ant-radio-button-wrapper-checked:not( .ant-radio-button-wrapper-disabled ):focus-within { diff --git a/superset-frontend/src/components/Chart/DrillBy/useDrillByBreadcrumbs.tsx b/superset-frontend/src/components/Chart/DrillBy/useDrillByBreadcrumbs.tsx index c815f4b5653a4..66f23249f484b 100644 --- a/superset-frontend/src/components/Chart/DrillBy/useDrillByBreadcrumbs.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/useDrillByBreadcrumbs.tsx @@ -41,12 +41,12 @@ const BreadcrumbItem = styled(AntdBreadcrumb.Item)<{ ${({ theme, isClickable, isHidden }) => css` cursor: ${isClickable ? 'pointer' : 'auto'}; color: ${theme.colors.grayscale.light1}; - transition: color ease-in ${theme.transitionTiming}s; + transition: color ease-in ${theme.motionDurationMid}; .ant-breadcrumb > span:last-child > & { - color: ${theme.colors.grayscale.dark1}; + color: ${theme.colorText}; } &:hover { - color: ${isClickable ? theme.colors.grayscale.dark1 : 'inherit'}; + color: ${isClickable ? theme.colorText : 'inherit'}; } visibility: ${isHidden ? 'hidden' : 'visible'}; `} @@ -78,7 +78,7 @@ export const useDrillByBreadcrumbs = ( return ( css` - margin: ${theme.gridUnit * 2}px 0 ${theme.gridUnit * 4}px; + margin: ${theme.sizeUnit * 2}px 0 ${theme.sizeUnit * 4}px; `} > {breadcrumbsData diff --git a/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx b/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx index 4d85f949b294c..5b01a5fad6af9 100644 --- a/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx @@ -25,7 +25,7 @@ const DATA_SIZE = 15; const PaginationContainer = styled.div` ${({ theme }) => css` & .pagination-container { - bottom: ${-theme.gridUnit * 4}px; + bottom: ${-theme.sizeUnit * 4}px; } `} `; diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.tsx index e20bc0290f777..a05f4c69ad49d 100644 --- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.tsx +++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.tsx @@ -89,8 +89,8 @@ const Filter = ({ const StyledFilter = styled(Filter)` ${({ theme }) => ` - font-weight: ${theme.typography.weights.bold}; - color: ${theme.colors.primary.base}; + font-weight: ${theme.fontWeightStrong}; + color: ${theme.colorPrimary}; `} `; diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx index fa8f22262cbdf..240acdc45c681 100644 --- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx +++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx @@ -69,7 +69,7 @@ const ModalFooter = ({ onClick={closeModal} data-test="close-drilltodetail-modal" css={css` - margin-left: ${theme.gridUnit * 2}px; + margin-left: ${theme.sizeUnit * 2}px; `} > {t('Close')} @@ -130,8 +130,8 @@ export default function DrillDetailModal({ responsive resizable resizableConfig={{ - minHeight: theme.gridUnit * 128, - minWidth: theme.gridUnit * 128, + minHeight: theme.sizeUnit * 128, + minWidth: theme.sizeUnit * 128, defaultSize: { width: 'auto', height: '75vh', diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx index bcab733f48c00..74cbe81bc62d7 100644 --- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx +++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx @@ -273,7 +273,7 @@ export default function DrillDetailPane({ tableContent = (
         {responseError}
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx
index cdf74c6f67f2e..4cdac34090e1f 100644
--- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx
+++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx
@@ -81,15 +81,15 @@ export default function TableControls({
       css={css`
         display: flex;
         justify-content: space-between;
-        padding: ${theme.gridUnit / 2}px 0;
-        margin-bottom: ${theme.gridUnit * 2}px;
+        padding: ${theme.sizeUnit / 2}px 0;
+        margin-bottom: ${theme.sizeUnit * 2}px;
       `}
     >
       
{filterTags.map(({ colName, val }) => ( @@ -98,19 +98,19 @@ export default function TableControls({ onClose={removeFilter.bind(null, colName)} key={colName} css={css` - height: ${theme.gridUnit * 6}px; + height: ${theme.sizeUnit * 6}px; display: flex; align-items: center; - padding: ${theme.gridUnit / 2}px ${theme.gridUnit * 2}px; - margin-right: ${theme.gridUnit * 4}px; - margin-bottom: ${theme.gridUnit * 4}px; + padding: ${theme.sizeUnit / 2}px ${theme.sizeUnit * 2}px; + margin-right: ${theme.sizeUnit * 4}px; + margin-bottom: ${theme.sizeUnit * 4}px; line-height: 1.2; `} data-test="filter-col" > {colName} diff --git a/superset-frontend/src/components/Checkbox/CheckboxIcons.tsx b/superset-frontend/src/components/Checkbox/CheckboxIcons.tsx index 2ad2d0f8d83df..9eb1bc5d5ea07 100644 --- a/superset-frontend/src/components/Checkbox/CheckboxIcons.tsx +++ b/superset-frontend/src/components/Checkbox/CheckboxIcons.tsx @@ -30,7 +30,7 @@ export const CheckboxChecked = () => { > { const arrowStyle = window.getComputedStyle(arrow); expect(headerStyle.fontWeight).toBe( - supersetTheme.typography.weights.bold.toString(), - ); - expect(headerStyle.fontSize).toBe(`${supersetTheme.gridUnit * 4}px`); - expect(headerStyle.color).toBe( - hexToRgb(supersetTheme.colors.grayscale.light4), + supersetTheme.fontWeightStrong.toString(), ); + expect(headerStyle.fontSize).toBe(`${supersetTheme.sizeUnit * 4}px`); expect(arrowStyle.transition).toBe('transform 0.24s'); }); diff --git a/superset-frontend/src/components/Collapse/index.tsx b/superset-frontend/src/components/Collapse/index.tsx index b2e0e206b6cde..00fe9484d09d7 100644 --- a/superset-frontend/src/components/Collapse/index.tsx +++ b/superset-frontend/src/components/Collapse/index.tsx @@ -35,11 +35,9 @@ const Collapse = Object.assign( .ant-collapse-item { .ant-collapse-header { font-weight: ${({ bold, theme }) => - bold - ? theme.typography.weights.bold - : theme.typography.weights.normal}; + bold ? theme.fontWeightStrong : theme.fontWeightNormal}; font-size: ${({ bigger, theme }) => - bigger ? `${theme.gridUnit * 4}px` : 'inherit'}; + bigger ? `${theme.sizeUnit * 4}px` : 'inherit'}; .ant-collapse-arrow svg { transition: ${({ animateArrows }) => @@ -58,9 +56,9 @@ const Collapse = Object.assign( ${({ light, theme }) => light && ` - color: ${theme.colors.grayscale.light4}; + color: ${theme.colorTextSecondary}; .ant-collapse-arrow svg { - color: ${theme.colors.grayscale.light4}; + color: ${theme.colorTextSecondary}; } `} @@ -68,13 +66,13 @@ const Collapse = Object.assign( ghost && bordered && ` - border-bottom: 1px solid ${theme.colors.grayscale.light3}; + border-bottom: 1px solid ${theme.colorBorderSecondary}; `} } .ant-collapse-content { .ant-collapse-content-box { .loading.inline { - margin: ${({ theme }) => theme.gridUnit * 12}px auto; + margin: ${({ theme }) => theme.sizeUnit * 12}px auto; display: block; } } diff --git a/superset-frontend/src/components/CronPicker/CronPicker.tsx b/superset-frontend/src/components/CronPicker/CronPicker.tsx index 9c65106e18ca5..7b0528b1c1862 100644 --- a/superset-frontend/src/components/CronPicker/CronPicker.tsx +++ b/superset-frontend/src/components/CronPicker/CronPicker.tsx @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -import { ConfigProvider } from 'antd'; import { styled, t } from '@superset-ui/core'; import ReactCronPicker, { Locale, CronProps } from 'react-js-cron'; @@ -103,11 +102,7 @@ export const LOCALE: Locale = { }; export const CronPicker = styled((props: CronProps) => ( - trigger.parentElement as HTMLElement} - > - - + ))` ${({ theme }) => ` @@ -118,8 +113,8 @@ export const CronPicker = styled((props: CronProps) => ( :has(.react-js-cron-months) { display: grid !important; grid-template-columns: repeat(2, 50%); - column-gap: ${theme.gridUnit}px; - row-gap: ${theme.gridUnit * 2}px; + column-gap: ${theme.sizeUnit}px; + row-gap: ${theme.sizeUnit * 2}px; div:has(.react-js-cron-hours) { grid-column: span 2; display: flex; @@ -135,8 +130,8 @@ export const CronPicker = styled((props: CronProps) => ( :not(:has(.react-js-cron-months)) { display: grid; grid-template-columns: repeat(2, 50%); - column-gap: ${theme.gridUnit}px; - row-gap: ${theme.gridUnit * 2}px; + column-gap: ${theme.sizeUnit}px; + row-gap: ${theme.sizeUnit * 2}px; .react-js-cron-period { grid-column: span 2; } @@ -170,7 +165,7 @@ export const CronPicker = styled((props: CronProps) => ( } .react-js-cron-minutes > span { - padding-left: ${theme.gridUnit}px; + padding-left: ${theme.sizeUnit}px; } /* Sizing of select container */ @@ -192,7 +187,7 @@ export const CronPicker = styled((props: CronProps) => ( .react-js-cron-custom-select .ant-select-selection-placeholder { flex: auto; - border-radius: ${theme.gridUnit}px; + border-radius: ${theme.sizeUnit}px; } .react-js-cron-custom-select .ant-select-selection-overflow-item { @@ -201,7 +196,7 @@ export const CronPicker = styled((props: CronProps) => ( .react-js-cron-select > div:first-of-type, .react-js-cron-custom-select { - border-radius: ${theme.gridUnit}px; + border-radius: ${theme.sizeUnit}px; } `} `; diff --git a/superset-frontend/src/components/DatabaseSelector/index.tsx b/superset-frontend/src/components/DatabaseSelector/index.tsx index 3b677316a47eb..63e8e9cd3c7f0 100644 --- a/superset-frontend/src/components/DatabaseSelector/index.tsx +++ b/superset-frontend/src/components/DatabaseSelector/index.tsx @@ -46,8 +46,8 @@ const DatabaseSelectorWrapper = styled.div` display: flex; align-items: center; width: 30px; - margin-left: ${theme.gridUnit}px; - margin-top: ${theme.gridUnit * 5}px; + margin-left: ${theme.sizeUnit}px; + margin-top: ${theme.sizeUnit * 5}px; } .section { @@ -57,12 +57,12 @@ const DatabaseSelectorWrapper = styled.div` } .select { - width: calc(100% - 30px - ${theme.gridUnit}px); + width: calc(100% - 30px - ${theme.sizeUnit}px); flex: 1; } & > div { - margin-bottom: ${theme.gridUnit * 4}px; + margin-bottom: ${theme.sizeUnit * 4}px; } `} `; @@ -71,7 +71,7 @@ const LabelStyle = styled.div` display: flex; flex-direction: row; align-items: center; - margin-left: ${({ theme }) => theme.gridUnit - 2}px; + margin-left: ${({ theme }) => theme.sizeUnit - 2}px; .backend { overflow: visible; diff --git a/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx b/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx index 1164d083dca8c..821b91a2da215 100644 --- a/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx +++ b/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx @@ -96,7 +96,7 @@ const ConfirmModalStyled = styled.div` const StyledSpan = styled.span` cursor: pointer; - color: ${({ theme }) => theme.colors.primary.dark1}; + color: ${({ theme }) => theme.colorPrimaryText}; &: hover { color: ${({ theme }) => theme.colors.primary.dark2}; } @@ -288,7 +288,7 @@ const ChangeDatasourceModal: FunctionComponent = ({ ({ marginBottom: theme.gridUnit * 4 })} + css={theme => ({ marginBottom: theme.sizeUnit * 4 })} message={ <> {t('Warning!')} {CHANGE_WARNING_MSG} diff --git a/superset-frontend/src/components/Datasource/CollectionTable.tsx b/superset-frontend/src/components/Datasource/CollectionTable.tsx index 2345931f8c725..73631b72337ef 100644 --- a/superset-frontend/src/components/Datasource/CollectionTable.tsx +++ b/superset-frontend/src/components/Datasource/CollectionTable.tsx @@ -121,20 +121,20 @@ const CrudTableWrapper = styled.div<{ stickyHeader?: boolean }>` `} ${({ theme }) => ` th span { - vertical-align: ${theme.gridUnit * -2}px; + vertical-align: ${theme.sizeUnit * -2}px; } .text-right { text-align: right; } .empty-collection { - padding: ${theme.gridUnit * 2 + 2}px; + padding: ${theme.sizeUnit * 2 + 2}px; } .tiny-cell { - width: ${theme.gridUnit + 1}px; + width: ${theme.sizeUnit + 1}px; } i.fa-caret-down, i.fa-caret-up { - width: ${theme.gridUnit + 1}px; + width: ${theme.sizeUnit + 1}px; } td.expanded { border-top: 0; @@ -145,13 +145,13 @@ const CrudTableWrapper = styled.div<{ stickyHeader?: boolean }>` const CrudButtonWrapper = styled.div` text-align: right; - ${({ theme }) => `margin-bottom: ${theme.gridUnit * 2}px`} + ${({ theme }) => `margin-bottom: ${theme.sizeUnit * 2}px`} `; const StyledButtonWrapper = styled.span` ${({ theme }) => ` - margin-top: ${theme.gridUnit * 3}px; - margin-left: ${theme.gridUnit * 3}px; + margin-top: ${theme.sizeUnit * 3}px; + margin-left: ${theme.sizeUnit * 3}px; `} `; diff --git a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx index d30b67ad2a751..1820418634ce1 100644 --- a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx +++ b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx @@ -61,11 +61,11 @@ import Field from './Field'; const DatasourceContainer = styled.div` .change-warning { margin: 16px 10px 0; - color: ${({ theme }) => theme.colors.warning.base}; + color: ${({ theme }) => theme.colorWarning}; } .change-warning .bold { - font-weight: ${({ theme }) => theme.typography.weights.bold}; + font-weight: ${({ theme }) => theme.fontWeightStrong}; } .form-group.has-feedback > .help-block { @@ -82,7 +82,7 @@ const FlexRowContainer = styled.div` display: flex; svg { - margin-right: ${({ theme }) => theme.gridUnit}px; + margin-right: ${({ theme }) => theme.sizeUnit}px; } `; @@ -95,14 +95,14 @@ const StyledTableTabs = styled(Tabs)` const StyledBadge = styled(Badge)` .antd5-badge-count { - line-height: ${({ theme }) => theme.gridUnit * 4}px; - height: ${({ theme }) => theme.gridUnit * 4}px; - margin-left: ${({ theme }) => theme.gridUnit}px; + line-height: ${({ theme }) => theme.sizeUnit * 4}px; + height: ${({ theme }) => theme.sizeUnit * 4}px; + margin-left: ${({ theme }) => theme.sizeUnit}px; } `; const EditLockContainer = styled.div` - font-size: ${({ theme }) => theme.typography.sizes.s}px; + font-size: ${({ theme }) => theme.fontSizeSM}px; display: flex; align-items: center; a { @@ -112,14 +112,14 @@ const EditLockContainer = styled.div` const ColumnButtonWrapper = styled.div` text-align: right; - ${({ theme }) => `margin-bottom: ${theme.gridUnit * 2}px`} + ${({ theme }) => `margin-bottom: ${theme.sizeUnit * 2}px`} `; const StyledLabelWrapper = styled.div` display: flex; align-items: center; span { - margin-right: ${({ theme }) => theme.gridUnit}px; + margin-right: ${({ theme }) => theme.sizeUnit}px; } `; @@ -129,14 +129,14 @@ const StyledColumnsTabWrapper = styled.div` } .ant-tag { - margin-top: ${({ theme }) => theme.gridUnit}px; + margin-top: ${({ theme }) => theme.sizeUnit}px; } `; const StyledButtonWrapper = styled.span` ${({ theme }) => ` - margin-top: ${theme.gridUnit * 3}px; - margin-left: ${theme.gridUnit * 3}px; + margin-top: ${theme.sizeUnit * 3}px; + margin-left: ${theme.sizeUnit * 3}px; `} `; @@ -1224,7 +1224,7 @@ class DatasourceEditor extends PureComponent { if (this.state.errors.length > 0) { return ( ({ marginBottom: theme.gridUnit * 4 })} + css={theme => ({ marginBottom: theme.sizeUnit * 4 })} type="error" message={ <> @@ -1408,7 +1408,7 @@ class DatasourceEditor extends PureComponent { {this.renderErrors()} ({ marginBottom: theme.gridUnit * 4 })} + css={theme => ({ marginBottom: theme.sizeUnit * 4 })} type="warning" message={ <> diff --git a/superset-frontend/src/components/Datasource/DatasourceModal.tsx b/superset-frontend/src/components/Datasource/DatasourceModal.tsx index a6f812786f2e4..a422fc83ff4a6 100644 --- a/superset-frontend/src/components/Datasource/DatasourceModal.tsx +++ b/superset-frontend/src/components/Datasource/DatasourceModal.tsx @@ -245,8 +245,8 @@ const DatasourceModal: FunctionComponent = ({
({ - marginTop: theme.gridUnit * 4, - marginBottom: theme.gridUnit * 4, + marginTop: theme.sizeUnit * 4, + marginBottom: theme.sizeUnit * 4, })} type="warning" showIcon diff --git a/superset-frontend/src/components/Datasource/Field.tsx b/superset-frontend/src/components/Datasource/Field.tsx index 3751e414b1d97..5f1babe93ac60 100644 --- a/superset-frontend/src/components/Datasource/Field.tsx +++ b/superset-frontend/src/components/Datasource/Field.tsx @@ -80,7 +80,7 @@ export default function Field({
({ color: theme.colors.grayscale.base, - [inline ? 'marginLeft' : 'marginTop']: theme.gridUnit, + [inline ? 'marginLeft' : 'marginTop']: theme.sizeUnit, })} > {description} diff --git a/superset-frontend/src/components/DatePicker/DatePicker.stories.tsx b/superset-frontend/src/components/DatePicker/DatePicker.stories.tsx index 563f48f07f7f6..0ea5c8dfb14a5 100644 --- a/superset-frontend/src/components/DatePicker/DatePicker.stories.tsx +++ b/superset-frontend/src/components/DatePicker/DatePicker.stories.tsx @@ -87,9 +87,11 @@ InteractiveDatePicker.args = { InteractiveDatePicker.argTypes = interactiveTypes; -export const InteractiveRangePicker = (args: RangePickerProps) => ( - -); +export const InteractiveRangePicker = ( + args: Omit & { + picker?: 'date'; + }, +) => ; InteractiveRangePicker.args = { ...commonArgs, diff --git a/superset-frontend/src/components/DeleteModal/index.tsx b/superset-frontend/src/components/DeleteModal/index.tsx index 11991854debcf..4fb9dbaaa346d 100644 --- a/superset-frontend/src/components/DeleteModal/index.tsx +++ b/superset-frontend/src/components/DeleteModal/index.tsx @@ -31,7 +31,7 @@ const StyledDiv = styled.div` `; const DescriptionContainer = styled.div` - line-height: ${({ theme }) => theme.gridUnit * 4}px; + line-height: ${({ theme }) => theme.sizeUnit * 4}px; padding-top: 16px; `; diff --git a/superset-frontend/src/components/Dropdown/index.tsx b/superset-frontend/src/components/Dropdown/index.tsx index ef81bd42ccd07..7fa6477aca4f8 100644 --- a/superset-frontend/src/components/Dropdown/index.tsx +++ b/superset-frontend/src/components/Dropdown/index.tsx @@ -35,21 +35,21 @@ import { styled } from '@superset-ui/core'; import Icons from 'src/components/Icons'; const MenuDots = styled.div` - width: ${({ theme }) => theme.gridUnit * 0.75}px; - height: ${({ theme }) => theme.gridUnit * 0.75}px; + width: ${({ theme }) => theme.sizeUnit * 0.75}px; + height: ${({ theme }) => theme.sizeUnit * 0.75}px; border-radius: 50%; background-color: ${({ theme }) => theme.colors.grayscale.light1}; - font-weight: ${({ theme }) => theme.typography.weights.normal}; + font-weight: ${({ theme }) => theme.fontWeightNormal}; display: inline-flex; position: relative; &:hover { - background-color: ${({ theme }) => theme.colors.primary.base}; + background-color: ${({ theme }) => theme.colorPrimary}; &::before, &::after { - background-color: ${({ theme }) => theme.colors.primary.base}; + background-color: ${({ theme }) => theme.colorPrimary}; } } @@ -57,26 +57,26 @@ const MenuDots = styled.div` &::after { position: absolute; content: ' '; - width: ${({ theme }) => theme.gridUnit * 0.75}px; - height: ${({ theme }) => theme.gridUnit * 0.75}px; + width: ${({ theme }) => theme.sizeUnit * 0.75}px; + height: ${({ theme }) => theme.sizeUnit * 0.75}px; border-radius: 50%; background-color: ${({ theme }) => theme.colors.grayscale.light1}; } &::before { - top: ${({ theme }) => theme.gridUnit}px; + top: ${({ theme }) => theme.sizeUnit}px; } &::after { - bottom: ${({ theme }) => theme.gridUnit}px; + bottom: ${({ theme }) => theme.sizeUnit}px; } `; const MenuDotsWrapper = styled.div` display: flex; align-items: center; - padding: ${({ theme }) => theme.gridUnit * 2}px; - padding-left: ${({ theme }) => theme.gridUnit}px; + padding: ${({ theme }) => theme.sizeUnit * 2}px; + padding-left: ${({ theme }) => theme.sizeUnit}px; `; export enum IconOrientation { diff --git a/superset-frontend/src/components/DropdownButton/index.tsx b/superset-frontend/src/components/DropdownButton/index.tsx index 32a7739e3c308..a04bd1ff17f60 100644 --- a/superset-frontend/src/components/DropdownButton/index.tsx +++ b/superset-frontend/src/components/DropdownButton/index.tsx @@ -25,7 +25,7 @@ import { kebabCase } from 'lodash'; const StyledDropdownButton = styled.div` .ant-btn-group { button.ant-btn { - background-color: ${({ theme }) => theme.colors.primary.dark1}; + background-color: ${({ theme }) => theme.colorPrimaryText}; border-color: transparent; color: ${({ theme }) => theme.colors.grayscale.light5}; font-size: 12px; @@ -33,7 +33,7 @@ const StyledDropdownButton = styled.div` outline: none; &:first-of-type { border-radius: ${({ theme }) => - `${theme.gridUnit}px 0 0 ${theme.gridUnit}px`}; + `${theme.sizeUnit}px 0 0 ${theme.sizeUnit}px`}; margin: 0; } @@ -44,17 +44,17 @@ const StyledDropdownButton = styled.div` &:nth-of-type(2) { margin: 0; border-radius: ${({ theme }) => - `0 ${theme.gridUnit}px ${theme.gridUnit}px 0`}; - width: ${({ theme }) => theme.gridUnit * 9}px; + `0 ${theme.sizeUnit}px ${theme.sizeUnit}px 0`}; + width: ${({ theme }) => theme.sizeUnit * 9}px; &:before, &:hover:before { border-left: 1px solid ${({ theme }) => theme.colors.grayscale.light5}; content: ''; display: block; - height: ${({ theme }) => theme.gridUnit * 8}px; + height: ${({ theme }) => theme.sizeUnit * 8}px; margin: 0; position: absolute; - width: ${({ theme }) => theme.gridUnit * 0.25}px; + width: ${({ theme }) => theme.sizeUnit * 0.25}px; } &:disabled:before { diff --git a/superset-frontend/src/components/DropdownContainer/index.tsx b/superset-frontend/src/components/DropdownContainer/index.tsx index 744b7f61de48a..1d6de309a02e9 100644 --- a/superset-frontend/src/components/DropdownContainer/index.tsx +++ b/superset-frontend/src/components/DropdownContainer/index.tsx @@ -264,7 +264,7 @@ const DropdownContainer = forwardRef( css={css` display: flex; flex-direction: column; - gap: ${theme.gridUnit * 4}px; + gap: ${theme.sizeUnit * 4}px; `} data-test="dropdown-content" style={dropdownStyle} @@ -278,7 +278,7 @@ const DropdownContainer = forwardRef( [ dropdownContent, overflowingCount, - theme.gridUnit, + theme.sizeUnit, dropdownStyle, overflowedItems, ], @@ -328,8 +328,8 @@ const DropdownContainer = forwardRef( css={css` display: flex; align-items: center; - gap: ${theme.gridUnit * 4}px; - margin-right: ${theme.gridUnit * 4}px; + gap: ${theme.sizeUnit * 4}px; + margin-right: ${theme.sizeUnit * 4}px; min-width: 0px; `} data-test="container" @@ -344,7 +344,7 @@ const DropdownContainer = forwardRef( .ant-popover-inner-content { max-height: ${MAX_HEIGHT}px; overflow: ${showOverflow ? 'auto' : 'visible'}; - padding: ${theme.gridUnit * 3}px ${theme.gridUnit * 4}px; + padding: ${theme.sizeUnit * 3}px ${theme.sizeUnit * 4}px; // Some OS versions only show the scroll when hovering. // These settings will make the scroll always visible. @@ -384,12 +384,12 @@ const DropdownContainer = forwardRef( count={dropdownTriggerCount ?? overflowingCount} color={ (dropdownTriggerCount ?? overflowingCount) > 0 - ? theme.colors.primary.base + ? theme.colorPrimary : theme.colors.grayscale.light1 } showZero css={css` - margin-left: ${theme.gridUnit * 2}px; + margin-left: ${theme.sizeUnit * 2}px; `} /> { {label} {selectedKeys?.includes(key) && ( @@ -130,7 +130,7 @@ export default (props: DropDownSelectableProps) => { ), - [selectedKeys, theme.colors.primary.base], + [selectedKeys, theme.colorPrimary], ); const overlayMenu = useMemo( diff --git a/superset-frontend/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx b/superset-frontend/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx index fbf33106e76a1..b11f50825df55 100644 --- a/superset-frontend/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx +++ b/superset-frontend/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx @@ -18,7 +18,7 @@ */ import userEvent from '@testing-library/user-event'; import { render, screen } from 'spec/helpers/testing-library'; -import { DynamicEditableTitle } from '.'; +import DynamicEditableTitle from '.'; const createProps = (overrides: Record = {}) => ({ title: 'Chart title', diff --git a/superset-frontend/src/components/DynamicEditableTitle/index.tsx b/superset-frontend/src/components/DynamicEditableTitle/index.tsx index dd439194383ad..695a4071ab17e 100644 --- a/superset-frontend/src/components/DynamicEditableTitle/index.tsx +++ b/superset-frontend/src/components/DynamicEditableTitle/index.tsx @@ -41,8 +41,8 @@ export type DynamicEditableTitleProps = { const titleStyles = (theme: SupersetTheme) => css` display: flex; - font-size: ${theme.typography.sizes.xl}px; - font-weight: ${theme.typography.weights.bold}; + font-size: ${theme.fontSizeXL}px; + font-weight: ${theme.fontWeightStrong}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; @@ -63,9 +63,11 @@ const titleStyles = (theme: SupersetTheme) => css` border: none; padding: 0; outline: none; + color: ${theme.colorText}; + background-color: ${theme.colorBgContainer}; &::placeholder { - color: ${theme.colors.grayscale.light1}; + color: ${theme.colorTextTertiary}; } } @@ -77,7 +79,7 @@ const titleStyles = (theme: SupersetTheme) => css` } `; -export const DynamicEditableTitle = memo( +const DynamicEditableTitle = memo( ({ title, placeholder, @@ -224,3 +226,4 @@ export const DynamicEditableTitle = memo( ); }, ); +export default DynamicEditableTitle; diff --git a/superset-frontend/src/components/EditableTitle/index.tsx b/superset-frontend/src/components/EditableTitle/index.tsx index fc01fb9f63b99..73047e2b84e84 100644 --- a/superset-frontend/src/components/EditableTitle/index.tsx +++ b/superset-frontend/src/components/EditableTitle/index.tsx @@ -224,7 +224,7 @@ export default function EditableTitle({ to={url} data-test="editable-title-input" css={(theme: SupersetTheme) => css` - color: ${theme.colors.grayscale.dark1}; + color: ${theme.colorText}; text-decoration: none; :hover { text-decoration: underline; diff --git a/superset-frontend/src/components/EmptyState/index.tsx b/superset-frontend/src/components/EmptyState/index.tsx index a083b6cdcfaa8..d1c973619d619 100644 --- a/superset-frontend/src/components/EmptyState/index.tsx +++ b/superset-frontend/src/components/EmptyState/index.tsx @@ -74,10 +74,10 @@ const EmptyStateContainer = styled.div` flex-direction: column; width: 100%; height: 100%; - color: ${theme.colors.grayscale.light2}; + color: ${theme.colorTextQuaternary}; align-items: center; justify-content: center; - padding: ${theme.gridUnit * 4}px; + padding: ${theme.sizeUnit * 4}px; text-align: center; & .antd5-empty-image svg { @@ -97,28 +97,24 @@ const EmptyStateContainer = styled.div` const Title = styled.p<{ size: EmptyStateSize }>` ${({ theme, size }) => css` - font-size: ${size === 'large' - ? theme.typography.sizes.l - : theme.typography.sizes.m}px; + font-size: ${size === 'large' ? theme.fontSizeLG : theme.fontSize}px; color: ${theme.colors.grayscale.light1}; - margin-top: ${size === 'large' ? theme.gridUnit * 4 : theme.gridUnit * 2}px; - font-weight: ${theme.typography.weights.bold}; + margin-top: ${size === 'large' ? theme.sizeUnit * 4 : theme.sizeUnit * 2}px; + font-weight: ${theme.fontWeightStrong}; `} `; const Description = styled.p<{ size: EmptyStateSize }>` ${({ theme, size }) => css` - font-size: ${size === 'large' - ? theme.typography.sizes.m - : theme.typography.sizes.s}px; + font-size: ${size === 'large' ? theme.fontSize : theme.fontSizeSM}px; color: ${theme.colors.grayscale.light1}; - margin-top: ${theme.gridUnit * 2}px; + margin-top: ${theme.sizeUnit * 2}px; `} `; const ActionButton = styled(Button)` ${({ theme }) => css` - margin-top: ${theme.gridUnit * 4}px; + margin-top: ${theme.sizeUnit * 4}px; z-index: 1; `} `; @@ -175,8 +171,8 @@ export const EmptyState: React.FC = ({
css` max-width: ${size === 'large' - ? theme.gridUnit * 150 - : theme.gridUnit * 100}px; + ? theme.sizeUnit * 150 + : theme.sizeUnit * 100}px; `} > {title && {title}} diff --git a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx index 9a2b0f103ce07..5e1a2ecce3c84 100644 --- a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx @@ -70,7 +70,7 @@ test('should render with warning theme', () => { render(); expect(screen.getByRole('alert')).toHaveStyle( ` - backgroundColor: ${supersetTheme.colors.warning.light2}; + color: ${supersetTheme.colorWarningText}; `, ); }); @@ -83,7 +83,7 @@ test('should render with error theme', () => { render(); expect(screen.getByRole('alert')).toHaveStyle( ` - backgroundColor: ${supersetTheme.colors.error.light2}; + color: ${supersetTheme.colorErrorText}; `, ); }); diff --git a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx index 39ae748970072..26f147bb738dd 100644 --- a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx +++ b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx @@ -16,30 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -import { ErrorLevel, styled, useTheme } from '@superset-ui/core'; +import { ErrorLevel, styled, themeObject, useTheme } from '@superset-ui/core'; import Icons from 'src/components/Icons'; -const StyledContainer = styled.div<{ level: ErrorLevel }>` - display: flex; - flex-direction: row; - background-color: ${({ level, theme }) => theme.colors[level].light2}; - border-radius: ${({ theme }) => theme.borderRadius}px; - border: 1px solid ${({ level, theme }) => theme.colors[level].base}; - color: ${({ level, theme }) => theme.colors[level].dark2}; - padding: ${({ theme }) => theme.gridUnit * 2}px; - margin-bottom: ${({ theme }) => theme.gridUnit}px; - width: 100%; -`; - const StyledContent = styled.div` display: flex; flex-direction: column; - margin-left: ${({ theme }) => theme.gridUnit * 2}px; + margin-left: ${({ theme }) => theme.sizeUnit * 2}px; overflow: hidden; `; const StyledTitle = styled.span` - font-weight: ${({ theme }) => theme.typography.weights.bold}; + font-weight: ${({ theme }) => theme.fontWeightStrong}; `; interface BasicErrorAlertProps { @@ -54,19 +42,30 @@ export default function BasicErrorAlert({ title, }: BasicErrorAlertProps) { const theme = useTheme(); - const iconColor = theme.colors[level].base; + const variants = themeObject.getColorVariants(level); + const style: React.CSSProperties = { + backgroundColor: variants.bg, + borderColor: variants.border, + color: variants.text, + display: 'flex', + flexDirection: 'row', + borderRadius: `${theme.borderRadius}px`, + padding: `${theme.sizeUnit * 2}px`, + marginBottom: `${theme.sizeUnit}px`, + width: '100%', + }; return ( - +
{level === 'error' ? ( - + ) : ( - + )} {title}

{body}

- +
); } diff --git a/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx b/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx index b7595c00fa8e0..ae683687b2534 100644 --- a/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx +++ b/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx @@ -32,10 +32,6 @@ Please check your query and ensure it follows the correct syntax.`; const detailsExample = `Additional details about the issue are provided here. This content is shown when the user clicks "Show more".`; -const ErrorCard: React.FC<{ children: React.ReactNode }> = ({ children }) => ( - {children} -); - export default { title: 'Components/ErrorAlert', component: ErrorAlert, @@ -47,12 +43,12 @@ export const Gallery: StoryFn = () => (

Non-Compact Errors

- + - + - + ( descriptionDetails={detailsExample} descriptionDetailsCollapsed /> - + - + ( descriptionDetailsCollapsed descriptionPre /> - + - + ( descriptionDetails={detailsExample} descriptionDetailsCollapsed={false} /> - + - + ( descriptionDetailsCollapsed={false} descriptionPre={false} /> - + - + - + - + - +

Compact Errors (with Modal)

- + ( description={sqlErrorDescription} descriptionDetails={detailsExample} /> - + - + ( descriptionDetails={detailsExample} descriptionDetailsCollapsed /> - + diff --git a/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx b/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx index a46b966072188..706d59f12190e 100644 --- a/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx @@ -17,7 +17,8 @@ * under the License. */ -import { screen, fireEvent, render } from 'spec/helpers/testing-library'; +import { screen, fireEvent } from '@testing-library/react'; +import { render } from 'spec/helpers/testing-library'; import ErrorAlert from './ErrorAlert'; describe('ErrorAlert', () => { diff --git a/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx b/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx index 50f21bf0fd411..898742c493844 100644 --- a/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx +++ b/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx @@ -64,7 +64,7 @@ const ErrorAlert: React.FC = ({ const icon = type === 'warning' ? : ; const color = - type === 'warning' ? theme.colors.warning.base : theme.colors.error.base; + type === 'warning' ? theme.colorWarningText : theme.colorErrorText; return (
{icon} @@ -74,7 +74,7 @@ const ErrorAlert: React.FC = ({ }; const preStyle = { whiteSpace: 'pre-wrap', - fontFamily: theme.typography.families.sansSerif, + fontFamily: theme.fontFamilyCode, }; const renderDescription = () => (
diff --git a/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx b/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx index 566e9d00d6f56..8949ab22269be 100644 --- a/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx +++ b/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx @@ -33,8 +33,8 @@ interface MarshmallowErrorExtra { } const StyledUl = styled.ul` - padding-left: ${({ theme }) => theme.gridUnit * 5}px; - padding-top: ${({ theme }) => theme.gridUnit * 4}px; + padding-left: ${({ theme }) => theme.sizeUnit * 5}px; + padding-top: ${({ theme }) => theme.sizeUnit * 4}px; `; const collapseStyle = (theme: SupersetTheme) => css` @@ -42,7 +42,7 @@ const collapseStyle = (theme: SupersetTheme) => css` left: 0px !important; } .ant-collapse-header { - padding-left: ${theme.gridUnit * 4}px !important; + padding-left: ${theme.sizeUnit * 4}px !important; } .ant-collapse-content-box { padding: 0px !important; diff --git a/superset-frontend/src/components/FaveStar/index.tsx b/superset-frontend/src/components/FaveStar/index.tsx index 49c7a71cd07a7..33345bf1a45d1 100644 --- a/superset-frontend/src/components/FaveStar/index.tsx +++ b/superset-frontend/src/components/FaveStar/index.tsx @@ -33,9 +33,9 @@ export interface FaveStarProps { const StyledLink = styled.a` ${({ theme }) => css` - font-size: ${theme.typography.sizes.xl}px; + font-size: ${theme.fontSizeXL}px; display: flex; - padding: 0 0 0 ${theme.gridUnit * 2}px; + padding: 0 0 0 ${theme.sizeUnit * 2}px; `}; `; diff --git a/superset-frontend/src/components/FilterableTable/index.tsx b/superset-frontend/src/components/FilterableTable/index.tsx index f77f4aede0eb7..6139e5037f548 100644 --- a/superset-frontend/src/components/FilterableTable/index.tsx +++ b/superset-frontend/src/components/FilterableTable/index.tsx @@ -41,7 +41,7 @@ const StyledFilterableTable = styled.div` overflow: hidden; .ant-table-cell { - font-weight: ${theme.typography.weights.bold}; + font-weight: ${theme.fontWeightStrong}; background-color: ${theme.colors.grayscale.light5}; } @@ -49,7 +49,7 @@ const StyledFilterableTable = styled.div` .virtual-table-cell { min-width: 0px; align-self: center; - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; } .even-row { @@ -61,8 +61,8 @@ const StyledFilterableTable = styled.div` } .cell-text-for-measuring { - font-family: ${theme.typography.families.sansSerif}; - font-size: ${theme.typography.sizes.s}px; + font-family: ${theme.fontFamily}; + font-size: ${theme.fontSizeSM}px; } `} `; diff --git a/superset-frontend/src/components/Form/Form.tsx b/superset-frontend/src/components/Form/Form.tsx index 143f0494bb870..c7731a2cde928 100644 --- a/superset-frontend/src/components/Form/Form.tsx +++ b/superset-frontend/src/components/Form/Form.tsx @@ -21,10 +21,10 @@ import { styled } from '@superset-ui/core'; const StyledForm = styled(AntdForm)` &.ant-form label { - font-size: ${({ theme }) => theme.typography.sizes.s}px; + font-size: ${({ theme }) => theme.fontSizeSM}px; } .ant-form-item { - margin-bottom: ${({ theme }) => theme.gridUnit * 4}px; + margin-bottom: ${({ theme }) => theme.sizeUnit * 4}px; } `; diff --git a/superset-frontend/src/components/Form/FormItem.tsx b/superset-frontend/src/components/Form/FormItem.tsx index dd829cd1e4867..35b86301b2377 100644 --- a/superset-frontend/src/components/Form/FormItem.tsx +++ b/superset-frontend/src/components/Form/FormItem.tsx @@ -22,9 +22,9 @@ import { styled } from '@superset-ui/core'; const StyledItem = styled(Form.Item)` ${({ theme }) => ` .ant-form-item-label { - padding-bottom: ${theme.gridUnit}px; + padding-bottom: ${theme.sizeUnit}px; & > label { - font-size: ${theme.typography.sizes.s}px; + font-size: ${theme.fontSizeSM}px; color: ${theme.colors.grayscale.base}; &.ant-form-item-required:not(.ant-form-item-required-mark-optional) { @@ -33,8 +33,8 @@ const StyledItem = styled(Form.Item)` } &::after { display: inline-block; - color: ${theme.colors.error.base}; - font-size: ${theme.typography.sizes.s}px; + color: ${theme.colorError}; + font-size: ${theme.fontSizeSM}px; content: '*'; } } diff --git a/superset-frontend/src/components/Form/FormLabel.tsx b/superset-frontend/src/components/Form/FormLabel.tsx index bf52dacb82bd1..e14b56c94b2fc 100644 --- a/superset-frontend/src/components/Form/FormLabel.tsx +++ b/superset-frontend/src/components/Form/FormLabel.tsx @@ -27,20 +27,20 @@ export type FormLabelProps = { }; const Label = styled.label` - font-size: ${({ theme }) => theme.typography.sizes.s}px; - color: ${({ theme }) => theme.colors.grayscale.base}; - margin-bottom: ${({ theme }) => theme.gridUnit}px; + font-size: ${({ theme }) => theme.fontSizeSM}px; + color: ${({ theme }) => theme.colors.grayscale.dark2}; + margin-bottom: ${({ theme }) => theme.sizeUnit}px; `; const RequiredLabel = styled.label` - font-size: ${({ theme }) => theme.typography.sizes.s}px; - color: ${({ theme }) => theme.colors.grayscale.base}; - margin-bottom: ${({ theme }) => theme.gridUnit}px; + font-size: ${({ theme }) => theme.fontSizeSM}px; + color: ${({ theme }) => theme.colors.grayscale.dark2}; + margin-bottom: ${({ theme }) => theme.sizeUnit}px; &::after { display: inline-block; - margin-left: ${({ theme }) => theme.gridUnit}px; - color: ${({ theme }) => theme.colors.error.base}; - font-size: ${({ theme }) => theme.typography.sizes.m}px; + margin-left: ${({ theme }) => theme.sizeUnit}px; + color: ${({ theme }) => theme.colorError}; + font-size: ${({ theme }) => theme.fontSize}px; content: '*'; } `; diff --git a/superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx b/superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx index bb05168078008..2fd1cbdfba8a3 100644 --- a/superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx +++ b/superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx @@ -42,11 +42,11 @@ export interface LabeledErrorBoundInputProps { } const StyledInput = styled(Input)` - margin: ${({ theme }) => `${theme.gridUnit}px 0 ${theme.gridUnit * 2}px`}; + margin: ${({ theme }) => `${theme.sizeUnit}px 0 ${theme.sizeUnit * 2}px`}; `; const StyledInputPassword = styled(Input.Password)` - margin: ${({ theme }) => `${theme.gridUnit}px 0 ${theme.gridUnit * 2}px`}; + margin: ${({ theme }) => `${theme.sizeUnit}px 0 ${theme.sizeUnit * 2}px`}; `; const alertIconStyles = (theme: SupersetTheme, hasError: boolean) => css` @@ -59,14 +59,14 @@ const alertIconStyles = (theme: SupersetTheme, hasError: boolean) => css` &:after { content: ' '; display: inline-block; - background: ${theme.colors.error.base}; + background: ${theme.colorError}; mask: url(${errorIcon}); mask-size: cover; - width: ${theme.gridUnit * 4}px; - height: ${theme.gridUnit * 4}px; + width: ${theme.sizeUnit * 4}px; + height: ${theme.sizeUnit * 4}px; position: absolute; - right: ${theme.gridUnit * 1.25}px; - top: ${theme.gridUnit * 2.75}px; + right: ${theme.sizeUnit * 1.25}px; + top: ${theme.sizeUnit * 2.75}px; } }`} `; @@ -77,7 +77,7 @@ const StyledFormGroup = styled('div')` -webkit-appearance: none; margin: 0; } - margin-bottom: ${({ theme }) => theme.gridUnit * 3}px; + margin-bottom: ${({ theme }) => theme.sizeUnit * 3}px; .ant-form-item { margin-bottom: 0; } diff --git a/superset-frontend/src/components/IconButton/index.tsx b/superset-frontend/src/components/IconButton/index.tsx index 654e4089f5a9c..338e6207d4472 100644 --- a/superset-frontend/src/components/IconButton/index.tsx +++ b/superset-frontend/src/components/IconButton/index.tsx @@ -35,13 +35,13 @@ const StyledButton = styled(Button)` `; const StyledImage = styled.div` - padding: ${({ theme }) => theme.gridUnit * 4}px; - height: ${({ theme }) => theme.gridUnit * 18}px; - margin: ${({ theme }) => theme.gridUnit * 3}px 0; + padding: ${({ theme }) => theme.sizeUnit * 4}px; + height: ${({ theme }) => theme.sizeUnit * 18}px; + margin: ${({ theme }) => theme.sizeUnit * 3}px 0; .default-db-icon { font-size: 36px; - color: ${({ theme }) => theme.colors.grayscale.base}; + color: ${({ theme }) => theme.colorIcon}; margin-right: 0; span:first-of-type { margin-right: 0; @@ -53,8 +53,8 @@ const StyledImage = styled.div` } img { - width: ${({ theme }) => theme.gridUnit * 10}px; - height: ${({ theme }) => theme.gridUnit * 10}px; + width: ${({ theme }) => theme.sizeUnit * 10}px; + height: ${({ theme }) => theme.sizeUnit * 10}px; margin: 0; &:first-of-type { margin-right: 0; @@ -83,10 +83,10 @@ const StyledInner = styled.div` `; const StyledBottom = styled.div` - padding: ${({ theme }) => theme.gridUnit * 4}px 0; + padding: ${({ theme }) => theme.sizeUnit * 4}px 0; border-radius: 0 0 ${({ theme }) => theme.borderRadius}px ${({ theme }) => theme.borderRadius}px; - background-color: ${({ theme }) => theme.colors.grayscale.light4}; + background-color: ${({ theme }) => theme.colorBgContainer}; width: 100%; line-height: 1.5em; overflow: hidden; @@ -125,19 +125,19 @@ const IconButton = styled( ), )` text-transform: none; - background-color: ${({ theme }) => theme.colors.grayscale.light5}; - font-weight: ${({ theme }) => theme.typography.weights.normal}; - color: ${({ theme }) => theme.colors.grayscale.dark2}; - border: 1px solid ${({ theme }) => theme.colors.grayscale.light2}; + background-color: ${({ theme }) => theme.colorBgContainer}; + font-weight: ${({ theme }) => theme.fontWeightNormal}; + color: ${({ theme }) => theme.colorText}; + border: 1px solid ${({ theme }) => theme.colorBorder}; margin: 0; width: 100%; &:hover, &:focus { - background-color: ${({ theme }) => theme.colors.grayscale.light5}; - color: ${({ theme }) => theme.colors.grayscale.dark2}; - border: 1px solid ${({ theme }) => theme.colors.grayscale.light2}; - box-shadow: 4px 4px 20px ${({ theme }) => theme.colors.grayscale.light2}; + background-color: ${({ theme }) => theme.colorBgTextHover}; + color: ${({ theme }) => theme.colorText}; + border: 1px solid ${({ theme }) => theme.colorBorder}; + box-shadow: ${({ theme }) => theme.boxShadowSecondary}; } `; diff --git a/superset-frontend/src/components/IconTooltip/index.tsx b/superset-frontend/src/components/IconTooltip/index.tsx index 376d8aa13b0e3..bb8c5bb7015d5 100644 --- a/superset-frontend/src/components/IconTooltip/index.tsx +++ b/superset-frontend/src/components/IconTooltip/index.tsx @@ -42,7 +42,7 @@ export interface Props { } const StyledSpan = styled.span` - color: ${({ theme }) => theme.colors.primary.dark1}; + color: ${({ theme }) => theme.colorPrimaryText}; &: hover { color: ${({ theme }) => theme.colors.primary.dark2}; } diff --git a/superset-frontend/src/components/Icons/Icon.tsx b/superset-frontend/src/components/Icons/Icon.tsx index 39e5627235ae8..466943a8c0b62 100644 --- a/superset-frontend/src/components/Icons/Icon.tsx +++ b/superset-frontend/src/components/Icons/Icon.tsx @@ -16,17 +16,14 @@ * specific language governing permissions and limitations * under the License. */ - import { FC, SVGProps, useEffect, useRef, useState } from 'react'; import AntdIcon from '@ant-design/icons'; -import { styled } from '@superset-ui/core'; import TransparentIcon from 'src/assets/images/icons/transparent.svg'; +import { themeObject, styled } from '@superset-ui/core'; import IconType from './IconType'; const AntdIconComponent = ({ - // eslint-disable-next-line @typescript-eslint/no-unused-vars iconColor, - // eslint-disable-next-line @typescript-eslint/no-unused-vars iconSize, viewBox, ...rest @@ -37,13 +34,10 @@ const AntdIconComponent = ({ export const StyledIcon = styled(AntdIconComponent)` ${({ iconColor }) => iconColor && `color: ${iconColor};`}; span { - // Fixing alignement on some of the icons + // Fixing alignment on some of the icons line-height: 0px; } - font-size: ${({ iconSize, theme }) => - iconSize - ? `${theme.typography.sizes[iconSize] || theme.typography.sizes.m}px` - : '24px'}; + font-size: ${({ iconSize, theme }) => themeObject.getFontSize(iconSize)}px; `; export interface IconProps extends IconType { diff --git a/superset-frontend/src/components/Icons/Icons.stories.tsx b/superset-frontend/src/components/Icons/Icons.stories.tsx index 1774176767da5..d384456ee9a4d 100644 --- a/superset-frontend/src/components/Icons/Icons.stories.tsx +++ b/superset-frontend/src/components/Icons/Icons.stories.tsx @@ -30,36 +30,38 @@ export default { const palette = { Default: null }; Object.entries(supersetTheme.colors).forEach(([familyName, family]) => { - Object.entries(family).forEach(([colorName, colorValue]) => { - palette[`${familyName} / ${colorName}`] = colorValue; - }); + Object.entries(family as Record).forEach( + ([colorName, colorValue]) => { + palette[`${familyName} / ${colorName}`] = colorValue; + }, + ); }); const IconSet = styled.div` display: grid; grid-template-columns: repeat(auto-fit, 180px); grid-auto-rows: 90px; - margin-top: ${({ theme }) => theme.gridUnit * 2}px; + margin-top: ${({ theme }) => theme.sizeUnit * 2}px; `; const IconBlock = styled.div` display: flex; flex-direction: column; align-items: center; - padding: ${({ theme }) => theme.gridUnit * 2}px; + padding: ${({ theme }) => theme.sizeUnit * 2}px; span { margin-top: ${({ theme }) => - 2 * theme.gridUnit}px; // Add spacing between icon and name + 2 * theme.sizeUnit}px; // Add spacing between icon and name font-size: ${({ theme }) => - theme.typography.sizes.s}; // Optional: adjust font size for elegance + theme.fontSizeSM}; // Optional: adjust font size for elegance color: ${({ theme }) => theme.colors.grayscale.base}; // Optional: subtle color for the name } `; const SearchBox = styled(Input.Search)` - margin-bottom: ${({ theme }) => theme.gridUnit * 4}px; + margin-bottom: ${({ theme }) => theme.sizeUnit * 4}px; width: 100%; max-width: 400px; `; diff --git a/superset-frontend/src/components/ImportModal/ImportErrorAlert.tsx b/superset-frontend/src/components/ImportModal/ImportErrorAlert.tsx new file mode 100644 index 0000000000000..62de6e0710c85 --- /dev/null +++ b/superset-frontend/src/components/ImportModal/ImportErrorAlert.tsx @@ -0,0 +1,68 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { FunctionComponent } from 'react'; +import { t } from '@superset-ui/core'; + +import { getDatabaseDocumentationLinks } from 'src/views/CRUD/hooks'; +import ErrorAlert from 'src/components/ErrorMessage/ErrorAlert'; + +const supersetTextDocs = getDatabaseDocumentationLinks(); +export const DOCUMENTATION_LINK = supersetTextDocs + ? supersetTextDocs.support + : 'https://superset.apache.org/docs/databases/installing-database-drivers'; + +export interface IProps { + errorMessage: string; + showDbInstallInstructions: boolean; +} + +const ImportErrorAlert: FunctionComponent = ({ + errorMessage, + showDbInstallInstructions, +}) => ( + +
+ {t( + 'Database driver for importing maybe not installed. Visit the Superset documentation page for installation instructions: ', + )} + + {t('here')} + + . + + ) : ( + '' + ) + } + /> +); + +export default ImportErrorAlert; diff --git a/superset-frontend/src/components/ImportModal/index.tsx b/superset-frontend/src/components/ImportModal/index.tsx index 69d8f3a751331..207fd72c12e65 100644 --- a/superset-frontend/src/components/ImportModal/index.tsx +++ b/superset-frontend/src/components/ImportModal/index.tsx @@ -26,20 +26,20 @@ import Modal from 'src/components/Modal'; import { Upload } from 'src/components'; import { useImportResource } from 'src/views/CRUD/hooks'; import { ImportResourceName } from 'src/views/CRUD/types'; -import ErrorAlert from './ErrorAlert'; +import ImportErrorAlert from './ImportErrorAlert'; const HelperMessage = styled.div` display: block; color: ${({ theme }) => theme.colors.grayscale.base}; - font-size: ${({ theme }) => theme.typography.sizes.s}px; + font-size: ${({ theme }) => theme.fontSizeSM}px; `; const StyledInputContainer = styled.div` - padding-bottom: ${({ theme }) => theme.gridUnit * 2}px; - padding-top: ${({ theme }) => theme.gridUnit * 2}px; + padding-bottom: ${({ theme }) => theme.sizeUnit * 2}px; + padding-top: ${({ theme }) => theme.sizeUnit * 2}px; & > div { - margin: ${({ theme }) => theme.gridUnit}px 0; + margin: ${({ theme }) => theme.sizeUnit}px 0; } &.extra-container { @@ -47,7 +47,7 @@ const StyledInputContainer = styled.div` } .confirm-overwrite { - margin-bottom: ${({ theme }) => theme.gridUnit * 2}px; + margin-bottom: ${({ theme }) => theme.sizeUnit * 2}px; } .input-container { @@ -56,11 +56,11 @@ const StyledInputContainer = styled.div` label { display: flex; - margin-right: ${({ theme }) => theme.gridUnit * 2}px; + margin-right: ${({ theme }) => theme.sizeUnit * 2}px; } i { - margin: 0 ${({ theme }) => theme.gridUnit}px; + margin: 0 ${({ theme }) => theme.sizeUnit}px; } } @@ -82,11 +82,11 @@ const StyledInputContainer = styled.div` textarea, input[type='text'], input[type='number'] { - padding: ${({ theme }) => theme.gridUnit * 1.5}px - ${({ theme }) => theme.gridUnit * 2}px; + padding: ${({ theme }) => theme.sizeUnit * 1.5}px + ${({ theme }) => theme.sizeUnit * 2}px; border-style: none; border: 1px solid ${({ theme }) => theme.colors.grayscale.light2}; - border-radius: ${({ theme }) => theme.gridUnit}px; + border-radius: ${({ theme }) => theme.sizeUnit}px; &[name='name'] { flex: 0 1 auto; @@ -94,7 +94,7 @@ const StyledInputContainer = styled.div` } &[name='sqlalchemy_uri'] { - margin-right: ${({ theme }) => theme.gridUnit * 3}px; + margin-right: ${({ theme }) => theme.sizeUnit * 3}px; } } `; @@ -447,7 +447,7 @@ const ImportModelsModal: FunctionComponent = ({ {errorMessage && ( - 0 || diff --git a/superset-frontend/src/components/ImportModal/styles.ts b/superset-frontend/src/components/ImportModal/styles.ts index f0120f62398bf..859ff7093e835 100644 --- a/superset-frontend/src/components/ImportModal/styles.ts +++ b/superset-frontend/src/components/ImportModal/styles.ts @@ -20,7 +20,7 @@ import { css, SupersetTheme } from '@superset-ui/core'; export const antdWarningAlertStyles = (theme: SupersetTheme) => css` - margin: ${theme.gridUnit * 4}px 0; + margin: ${theme.sizeUnit * 4}px 0; .antd5-alert-message { margin: 0; diff --git a/superset-frontend/src/components/IndeterminateCheckbox/index.tsx b/superset-frontend/src/components/IndeterminateCheckbox/index.tsx index bfe85989ada27..baad62bd1f070 100644 --- a/superset-frontend/src/components/IndeterminateCheckbox/index.tsx +++ b/superset-frontend/src/components/IndeterminateCheckbox/index.tsx @@ -44,7 +44,7 @@ const CheckboxLabel = styled.label` `; const CheckboxHalf = styled(Icons.CheckboxHalf)` - color: ${({ theme }) => theme.colors.primary.base}; + color: ${({ theme }) => theme.colorPrimary}; cursor: pointer; `; @@ -54,7 +54,7 @@ const CheckboxOff = styled(Icons.CheckboxOff)` `; const CheckboxOn = styled(Icons.CheckboxOn)` - color: ${({ theme }) => theme.colors.primary.base}; + color: ${({ theme }) => theme.colorPrimary}; cursor: pointer; `; diff --git a/superset-frontend/src/components/Input/Input.stories.tsx b/superset-frontend/src/components/Input/Input.stories.tsx index 4023c53d97e0f..737c1a859cb76 100644 --- a/superset-frontend/src/components/Input/Input.stories.tsx +++ b/superset-frontend/src/components/Input/Input.stories.tsx @@ -19,7 +19,6 @@ import { InputProps, TextAreaProps } from 'antd-v5/lib/input'; import { InputNumberProps } from 'antd-v5/lib/input-number'; -import { AntdThemeProvider } from 'src/components/AntdThemeProvider'; import { Input, TextArea, InputNumber } from '.'; export default { @@ -27,22 +26,14 @@ export default { component: Input, }; -export const InteractiveInput = (args: InputProps) => ( - - - -); +export const InteractiveInput = (args: InputProps) => ; export const InteractiveInputNumber = (args: InputNumberProps) => ( - - - + ); export const InteractiveTextArea = (args: TextAreaProps) => ( - -