mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-14 10:19:51 +00:00
build(ui): Sort imports and enforce absolute imports with aliases (#13113)
This commit is contained in:
parent
dbad52283b
commit
45ebaa7d1a
@ -2,3 +2,4 @@
|
|||||||
dist/
|
dist/
|
||||||
build/
|
build/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
**/*.generated.ts
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module.exports = {
|
|||||||
'plugin:vitest/recommended',
|
'plugin:vitest/recommended',
|
||||||
'prettier',
|
'prettier',
|
||||||
],
|
],
|
||||||
plugins: ['@typescript-eslint', '@stylistic/js', 'react-refresh'],
|
plugins: ['@typescript-eslint', '@stylistic/js', 'react-refresh', 'import-alias'],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
|
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
|
||||||
sourceType: 'module', // Allows for the use of imports
|
sourceType: 'module', // Allows for the use of imports
|
||||||
@ -23,6 +23,7 @@ module.exports = {
|
|||||||
'arrow-body-style': 'off',
|
'arrow-body-style': 'off',
|
||||||
'class-methods-use-this': 'off',
|
'class-methods-use-this': 'off',
|
||||||
'import/no-extraneous-dependencies': 'off',
|
'import/no-extraneous-dependencies': 'off',
|
||||||
|
'import/no-relative-packages': 'error',
|
||||||
'import/prefer-default-export': 'off', // TODO: remove this lint rule
|
'import/prefer-default-export': 'off', // TODO: remove this lint rule
|
||||||
'no-console': 'off',
|
'no-console': 'off',
|
||||||
'no-plusplus': 'off',
|
'no-plusplus': 'off',
|
||||||
@ -50,18 +51,36 @@ module.exports = {
|
|||||||
'vitest/prefer-to-be': 'off',
|
'vitest/prefer-to-be': 'off',
|
||||||
'@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: false }],
|
'@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: false }],
|
||||||
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
||||||
|
'import-alias/import-alias': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
aliases: [
|
||||||
|
// Must be kept consistent with tsconfig.json, vite.config.ts, and .prettierrc.js
|
||||||
|
{ alias: '@components/', matcher: '^src/alchemy-components/' },
|
||||||
|
{ alias: '@app/', matcher: '^src/app/' },
|
||||||
|
{ alias: '@conf/', matcher: '^src/conf/' },
|
||||||
|
{ alias: '@graphql/', matcher: '^src/graphql/' },
|
||||||
|
{ alias: '@graphql-mock/', matcher: '^src/graphql-mock/' },
|
||||||
|
{ alias: '@images/', matcher: '^src/images/' },
|
||||||
|
{ alias: '@providers/', matcher: '^src/providers/' },
|
||||||
|
{ alias: '@utils/', matcher: '^src/utils/' },
|
||||||
|
{ alias: '@types', matcher: '^src/types.generated' },
|
||||||
|
{ alias: '@src/', matcher: '^src/' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
react: {
|
react: {
|
||||||
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
|
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
files: ['src/app/searchV2/**/*.tsx', 'src/app/entityV2/**/*.tsx'],
|
files: ['src/app/searchV2/**/*.tsx', 'src/app/entityV2/**/*.tsx'],
|
||||||
rules: {
|
rules: {
|
||||||
'import/no-cycle': 'off',
|
'import/no-cycle': 'off',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,4 +4,16 @@ module.exports = {
|
|||||||
singleQuote: true,
|
singleQuote: true,
|
||||||
printWidth: 120,
|
printWidth: 120,
|
||||||
tabWidth: 4,
|
tabWidth: 4,
|
||||||
|
plugins: ['@trivago/prettier-plugin-sort-imports'],
|
||||||
|
importOrder: [
|
||||||
|
// Third party imports are first automatically, in their own group
|
||||||
|
'^@components/(.*)$',
|
||||||
|
// Have to specify all aliases otherwise they're considered third party
|
||||||
|
'^(@app|@conf|@providers|@utils|@src)/(.*)$',
|
||||||
|
'^(@graphql/|@graphql-mock/|@types)(.*)$',
|
||||||
|
'^@images/(.*)$',
|
||||||
|
'^[./]',
|
||||||
|
],
|
||||||
|
importOrderSeparation: true,
|
||||||
|
importOrderSortSpecifiers: true,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -110,7 +110,7 @@
|
|||||||
"test-coverage": "yarn test run --coverage",
|
"test-coverage": "yarn test run --coverage",
|
||||||
"generate": "NODE_OPTIONS='--max-old-space-size=5120 --openssl-legacy-provider' graphql-codegen --config codegen.yml",
|
"generate": "NODE_OPTIONS='--max-old-space-size=5120 --openssl-legacy-provider' graphql-codegen --config codegen.yml",
|
||||||
"lint": "eslint . --ext .ts,.tsx --quiet && yarn format-check && yarn type-check",
|
"lint": "eslint . --ext .ts,.tsx --quiet && yarn format-check && yarn type-check",
|
||||||
"lint-fix": "eslint '*/**/*.{ts,tsx}' --quiet --fix && yarn format",
|
"lint-fix": "eslint . --ext .ts,.tsx --quiet --fix && yarn format",
|
||||||
"format-check": "prettier --check src",
|
"format-check": "prettier --check src",
|
||||||
"format": "prettier --write src",
|
"format": "prettier --write src",
|
||||||
"type-check": "tsc --noEmit",
|
"type-check": "tsc --noEmit",
|
||||||
@ -146,6 +146,7 @@
|
|||||||
"@storybook/test": "^8.1.11",
|
"@storybook/test": "^8.1.11",
|
||||||
"@storybook/theming": "^8.1.11",
|
"@storybook/theming": "^8.1.11",
|
||||||
"@stylistic/eslint-plugin-js": "^3.1.0",
|
"@stylistic/eslint-plugin-js": "^3.1.0",
|
||||||
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
||||||
"@types/graphql": "^14.5.0",
|
"@types/graphql": "^14.5.0",
|
||||||
"@types/query-string": "^6.3.0",
|
"@types/query-string": "^6.3.0",
|
||||||
"@types/styled-components": "^5.1.7",
|
"@types/styled-components": "^5.1.7",
|
||||||
@ -158,6 +159,7 @@
|
|||||||
"eslint-config-airbnb-typescript": "^17.0.0",
|
"eslint-config-airbnb-typescript": "^17.0.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-plugin-import": "^2.25.3",
|
"eslint-plugin-import": "^2.25.3",
|
||||||
|
"eslint-plugin-import-alias": "^1.2.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.5.1",
|
"eslint-plugin-jsx-a11y": "^6.5.1",
|
||||||
"eslint-plugin-react": "^7.28.0",
|
"eslint-plugin-react": "^7.28.0",
|
||||||
"eslint-plugin-react-hooks": "^4.3.0",
|
"eslint-plugin-react-hooks": "^4.3.0",
|
||||||
@ -165,7 +167,7 @@
|
|||||||
"eslint-plugin-vitest": "^0.3.17",
|
"eslint-plugin-vitest": "^0.3.17",
|
||||||
"jsdom": "^22.1.0",
|
"jsdom": "^22.1.0",
|
||||||
"less": "^4.2.0",
|
"less": "^4.2.0",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^3.5.3",
|
||||||
"source-map-explorer": "^2.5.2",
|
"source-map-explorer": "^2.5.2",
|
||||||
"storybook": "^8.1.11",
|
"storybook": "^8.1.11",
|
||||||
"vite": "^4.5.6",
|
"vite": "^4.5.6",
|
||||||
|
|||||||
@ -7,5 +7,7 @@
|
|||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'Manrope';
|
font-family: 'Manrope';
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
src: local('Manrope'), url('./fonts/manrope.woff2') format('woff2');
|
src:
|
||||||
|
local('Manrope'),
|
||||||
|
url('./fonts/manrope.woff2') format('woff2');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import React from 'react';
|
|
||||||
import { render } from '@testing-library/react';
|
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
import { InnerApp } from './App';
|
import { render } from '@testing-library/react';
|
||||||
import { mocks } from './Mocks';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { InnerApp } from '@src/App';
|
||||||
|
import { mocks } from '@src/Mocks';
|
||||||
|
|
||||||
// eslint-disable-next-line vitest/expect-expect
|
// eslint-disable-next-line vitest/expect-expect
|
||||||
test('renders the app', async () => {
|
test('renders the app', async () => {
|
||||||
|
|||||||
@ -1,19 +1,20 @@
|
|||||||
import React from 'react';
|
import { ApolloClient, ApolloProvider, InMemoryCache, ServerError, createHttpLink } from '@apollo/client';
|
||||||
import Cookies from 'js-cookie';
|
|
||||||
import { BrowserRouter as Router } from 'react-router-dom';
|
|
||||||
import { ApolloClient, ApolloProvider, createHttpLink, InMemoryCache, ServerError } from '@apollo/client';
|
|
||||||
import { onError } from '@apollo/client/link/error';
|
import { onError } from '@apollo/client/link/error';
|
||||||
|
import Cookies from 'js-cookie';
|
||||||
|
import React from 'react';
|
||||||
import { Helmet, HelmetProvider } from 'react-helmet-async';
|
import { Helmet, HelmetProvider } from 'react-helmet-async';
|
||||||
import './App.less';
|
import { BrowserRouter as Router } from 'react-router-dom';
|
||||||
import './AppV2.less';
|
|
||||||
import { Routes } from './app/Routes';
|
import { Routes } from '@app/Routes';
|
||||||
import { PageRoutes } from './conf/Global';
|
import { isLoggedInVar } from '@app/auth/checkAuthStatus';
|
||||||
import { isLoggedInVar } from './app/auth/checkAuthStatus';
|
import { ErrorCodes } from '@app/shared/constants';
|
||||||
import { GlobalCfg } from './conf';
|
import { PageRoutes } from '@conf/Global';
|
||||||
import possibleTypesResult from './possibleTypes.generated';
|
import '@src/App.less';
|
||||||
import { ErrorCodes } from './app/shared/constants';
|
import '@src/AppV2.less';
|
||||||
import CustomThemeProvider from './CustomThemeProvider';
|
import CustomThemeProvider from '@src/CustomThemeProvider';
|
||||||
import { useCustomTheme } from './customThemeContext';
|
import { GlobalCfg } from '@src/conf';
|
||||||
|
import { useCustomTheme } from '@src/customThemeContext';
|
||||||
|
import possibleTypesResult from '@src/possibleTypes.generated';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Construct Apollo Client
|
Construct Apollo Client
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import './App.less';
|
|
||||||
import { THIRD_PARTY_LOGGING_KEY } from './app/analytics/analytics';
|
import { THIRD_PARTY_LOGGING_KEY } from '@app/analytics/analytics';
|
||||||
import { checkAuthStatus } from './app/auth/checkAuthStatus';
|
import { checkAuthStatus } from '@app/auth/checkAuthStatus';
|
||||||
import { AppConfigContext, DEFAULT_APP_CONFIG } from './appConfigContext';
|
import '@src/App.less';
|
||||||
import { useAppConfigQuery } from './graphql/app.generated';
|
import { AppConfigContext, DEFAULT_APP_CONFIG } from '@src/appConfigContext';
|
||||||
|
|
||||||
|
import { useAppConfigQuery } from '@graphql/app.generated';
|
||||||
|
|
||||||
function changeFavicon(src) {
|
function changeFavicon(src) {
|
||||||
const links = document.querySelectorAll("link[rel~='icon']") as any;
|
const links = document.querySelectorAll("link[rel~='icon']") as any;
|
||||||
|
|||||||
@ -7,7 +7,9 @@
|
|||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'Manrope';
|
font-family: 'Manrope';
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
src: local('Manrope'), url('./fonts/manrope.woff2') format('woff2');
|
src:
|
||||||
|
local('Manrope'),
|
||||||
|
url('./fonts/manrope.woff2') format('woff2');
|
||||||
}
|
}
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { ThemeProvider } from 'styled-components';
|
import { ThemeProvider } from 'styled-components';
|
||||||
import { Theme } from './conf/theme/types';
|
|
||||||
import defaultThemeConfig from './conf/theme/theme_light.config.json';
|
import defaultThemeConfig from '@conf/theme/theme_light.config.json';
|
||||||
import { CustomThemeContext } from './customThemeContext';
|
import { Theme } from '@conf/theme/types';
|
||||||
|
import { CustomThemeContext } from '@src/customThemeContext';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@ -1,64 +1,66 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { GetDatasetDocument, UpdateDatasetDocument, GetDatasetSchemaDocument } from './graphql/dataset.generated';
|
|
||||||
import { GetDataFlowDocument } from './graphql/dataFlow.generated';
|
import { Entity } from '@app/entity/Entity';
|
||||||
import { GetDataJobDocument } from './graphql/dataJob.generated';
|
import { VIEW_ENTITY_PAGE } from '@app/entity/shared/constants';
|
||||||
import { GetBrowsePathsDocument, GetBrowseResultsDocument } from './graphql/browse.generated';
|
import { GenericEntityProperties } from '@app/entity/shared/types';
|
||||||
|
import { ViewBuilderState } from '@app/entity/view/types';
|
||||||
|
import { EntityCapabilityType } from '@app/entityV2/Entity';
|
||||||
|
import { FetchedEntity } from '@app/lineage/types';
|
||||||
|
import { DEFAULT_APP_CONFIG } from '@src/appConfigContext';
|
||||||
|
|
||||||
|
import { AppConfigDocument, GetEntityCountsDocument } from '@graphql/app.generated';
|
||||||
|
import { GetBrowsePathsDocument, GetBrowseResultsDocument } from '@graphql/browse.generated';
|
||||||
|
import { GetDataFlowDocument } from '@graphql/dataFlow.generated';
|
||||||
|
import { GetDataJobDocument } from '@graphql/dataJob.generated';
|
||||||
|
import { GetDatasetDocument, GetDatasetSchemaDocument, UpdateDatasetDocument } from '@graphql/dataset.generated';
|
||||||
|
import { GetGlossaryTermDocument, GetGlossaryTermQuery } from '@graphql/glossaryTerm.generated';
|
||||||
|
import { GetMeDocument } from '@graphql/me.generated';
|
||||||
|
import { GetMlModelDocument } from '@graphql/mlModel.generated';
|
||||||
|
import { GetMlModelGroupDocument } from '@graphql/mlModelGroup.generated';
|
||||||
|
import { GetGrantedPrivilegesDocument } from '@graphql/policy.generated';
|
||||||
|
import { GetQuickFiltersDocument } from '@graphql/quickFilters.generated';
|
||||||
|
import { ListRecommendationsDocument } from '@graphql/recommendations.generated';
|
||||||
import {
|
import {
|
||||||
GetAutoCompleteResultsDocument,
|
|
||||||
GetAutoCompleteMultipleResultsDocument,
|
GetAutoCompleteMultipleResultsDocument,
|
||||||
|
GetAutoCompleteResultsDocument,
|
||||||
GetSearchResultsDocument,
|
GetSearchResultsDocument,
|
||||||
GetSearchResultsQuery,
|
|
||||||
GetSearchResultsForMultipleDocument,
|
GetSearchResultsForMultipleDocument,
|
||||||
GetSearchResultsForMultipleQuery,
|
GetSearchResultsForMultipleQuery,
|
||||||
} from './graphql/search.generated';
|
GetSearchResultsQuery,
|
||||||
import { GetUserDocument } from './graphql/user.generated';
|
} from '@graphql/search.generated';
|
||||||
|
import { GetTagDocument } from '@graphql/tag.generated';
|
||||||
|
import { GetUserDocument } from '@graphql/user.generated';
|
||||||
import {
|
import {
|
||||||
Dataset,
|
|
||||||
DataFlow,
|
|
||||||
DataJob,
|
|
||||||
GlossaryTerm,
|
|
||||||
GlossaryNode,
|
|
||||||
EntityType,
|
|
||||||
PlatformType,
|
|
||||||
MlModel,
|
|
||||||
MlModelGroup,
|
|
||||||
SchemaFieldDataType,
|
|
||||||
ScenarioType,
|
|
||||||
RecommendationRenderType,
|
|
||||||
RelationshipDirection,
|
|
||||||
Container,
|
|
||||||
PlatformPrivileges,
|
|
||||||
FilterOperator,
|
|
||||||
AppConfig,
|
AppConfig,
|
||||||
EntityPrivileges,
|
|
||||||
BusinessAttribute,
|
BusinessAttribute,
|
||||||
EntityRelationshipsResult,
|
Container,
|
||||||
Maybe,
|
DataFlow,
|
||||||
SearchResult,
|
|
||||||
DataHubViewType,
|
|
||||||
LogicalOperator,
|
|
||||||
DataHubView,
|
DataHubView,
|
||||||
DataHubViewFilter,
|
DataHubViewFilter,
|
||||||
|
DataHubViewType,
|
||||||
|
DataJob,
|
||||||
|
Dataset,
|
||||||
|
EntityPrivileges,
|
||||||
|
EntityRelationshipsResult,
|
||||||
|
EntityType,
|
||||||
|
FilterOperator,
|
||||||
GlobalTags,
|
GlobalTags,
|
||||||
OwnershipType,
|
GlossaryNode,
|
||||||
|
GlossaryTerm,
|
||||||
|
LogicalOperator,
|
||||||
|
Maybe,
|
||||||
|
MlModel,
|
||||||
|
MlModelGroup,
|
||||||
Owner,
|
Owner,
|
||||||
} from './types.generated';
|
OwnershipType,
|
||||||
import { GetTagDocument } from './graphql/tag.generated';
|
PlatformPrivileges,
|
||||||
import { GetMlModelDocument } from './graphql/mlModel.generated';
|
PlatformType,
|
||||||
import { GetMlModelGroupDocument } from './graphql/mlModelGroup.generated';
|
RecommendationRenderType,
|
||||||
import { GetGlossaryTermDocument, GetGlossaryTermQuery } from './graphql/glossaryTerm.generated';
|
RelationshipDirection,
|
||||||
import { GetEntityCountsDocument, AppConfigDocument } from './graphql/app.generated';
|
ScenarioType,
|
||||||
import { GetMeDocument } from './graphql/me.generated';
|
SchemaFieldDataType,
|
||||||
import { ListRecommendationsDocument } from './graphql/recommendations.generated';
|
SearchResult,
|
||||||
import { FetchedEntity } from './app/lineage/types';
|
} from '@types';
|
||||||
import { DEFAULT_APP_CONFIG } from './appConfigContext';
|
|
||||||
import { GetQuickFiltersDocument } from './graphql/quickFilters.generated';
|
|
||||||
import { GetGrantedPrivilegesDocument } from './graphql/policy.generated';
|
|
||||||
import { VIEW_ENTITY_PAGE } from './app/entity/shared/constants';
|
|
||||||
import { Entity } from './app/entity/Entity';
|
|
||||||
import { GenericEntityProperties } from './app/entity/shared/types';
|
|
||||||
import { ViewBuilderState } from './app/entity/view/types';
|
|
||||||
import { EntityCapabilityType } from './app/entityV2/Entity';
|
|
||||||
|
|
||||||
export const entityPrivileges: EntityPrivileges = {
|
export const entityPrivileges: EntityPrivileges = {
|
||||||
canEditLineage: true,
|
canEditLineage: true,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { Meta, Source } from '@storybook/blocks';
|
import { Meta, Source } from '@storybook/blocks';
|
||||||
|
|
||||||
import { AVAILABLE_ICONS } from '@components';
|
import { AVAILABLE_ICONS } from '@components';
|
||||||
|
|
||||||
import { IconGalleryWithSearch } from './mdx-components';
|
import { IconGalleryWithSearch } from './mdx-components';
|
||||||
|
|
||||||
<Meta title="Icons" />
|
<Meta title="Icons" />
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { Meta, Description } from '@storybook/blocks';
|
import { Description, Meta } from '@storybook/blocks';
|
||||||
|
|
||||||
import ReadMe from '../README.mdx';
|
import ReadMe from '../README.mdx';
|
||||||
|
|
||||||
<Meta title="Introduction" />
|
<Meta title="Introduction" />
|
||||||
|
|||||||
@ -1,18 +1,19 @@
|
|||||||
import { Meta, Source } from '@storybook/blocks';
|
import { Meta, Source } from '@storybook/blocks';
|
||||||
|
|
||||||
import { Heading } from '@components';
|
import { Heading } from '@components';
|
||||||
|
|
||||||
import { colors } from '@components/theme';
|
import { colors } from '@components/theme';
|
||||||
|
|
||||||
import { Grid, FlexGrid, ColorCard, CopyButton, Seperator } from './mdx-components';
|
import { ColorCard, CopyButton, FlexGrid, Grid, Seperator } from './mdx-components';
|
||||||
|
|
||||||
import borderSource from '@components/theme/foundations/borders?raw';
|
import borderSource from '@components/theme/foundations/borders?raw';
|
||||||
import colorsSource from '@components/theme/foundations/colors?raw';
|
import colorsSource from '@components/theme/foundations/colors?raw';
|
||||||
import typographySource from '@components/theme/foundations/typography?raw';
|
|
||||||
import radiusSource from '@components/theme/foundations/radius?raw';
|
import radiusSource from '@components/theme/foundations/radius?raw';
|
||||||
import shadowsSource from '@components/theme/foundations/shadows?raw';
|
import shadowsSource from '@components/theme/foundations/shadows?raw';
|
||||||
import sizesSource from '@components/theme/foundations/sizes?raw';
|
import sizesSource from '@components/theme/foundations/sizes?raw';
|
||||||
import spacingSource from '@components/theme/foundations/spacing?raw';
|
import spacingSource from '@components/theme/foundations/spacing?raw';
|
||||||
import transitionSource from '@components/theme/foundations/transition?raw';
|
import transitionSource from '@components/theme/foundations/transition?raw';
|
||||||
|
import typographySource from '@components/theme/foundations/typography?raw';
|
||||||
import zIndexSource from '@components/theme/foundations/zIndex?raw';
|
import zIndexSource from '@components/theme/foundations/zIndex?raw';
|
||||||
|
|
||||||
<Meta title="Style Guide" />
|
<Meta title="Style Guide" />
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
|
import { DocsContext, Source } from '@storybook/blocks';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { Source, DocsContext } from '@storybook/blocks';
|
|
||||||
|
|
||||||
export const CodeBlock = () => {
|
export const CodeBlock = () => {
|
||||||
const context = React.useContext(DocsContext);
|
const context = React.useContext(DocsContext);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
|
import { Button, Icon } from '@components';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { Button, Icon } from '@components';
|
|
||||||
import { copyToClipboard } from './utils';
|
import { copyToClipboard } from './utils';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Docs Only Component that helps to display a list of components in a grid layout.
|
Docs Only Component that helps to display a list of components in a grid layout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { ReactNode } from 'react';
|
import React, { ReactNode } from 'react';
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
|
import { Button, ButtonProps, Icon } from '@components';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
import { Icon, Button, ButtonProps } from '@components';
|
import { IconDisplayBlock, IconGrid, IconGridItem } from './components';
|
||||||
import { IconGrid, IconGridItem, IconDisplayBlock } from './components';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
icons: string[];
|
icons: string[];
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Docs Only Components that helps to display information in info guides.
|
Docs Only Components that helps to display information in info guides.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import theme from '@components/theme';
|
import theme from '@components/theme';
|
||||||
|
|||||||
@ -42,9 +42,9 @@ You can access the theme types at `@components/theme/types` and the theme config
|
|||||||
|
|
||||||
Our docs are generated using [Storybook](https://storybook.js.org/) and deployed to [Cloudfare](https://www.cloudflare.com/).
|
Our docs are generated using [Storybook](https://storybook.js.org/) and deployed to [Cloudfare](https://www.cloudflare.com/).
|
||||||
|
|
||||||
- Storybook config is located at `.storybook`
|
- Storybook config is located at `.storybook`
|
||||||
- Static doc files are located at `alchemy-components/.docs`
|
- Static doc files are located at `alchemy-components/.docs`
|
||||||
- Component stories are located in each component directory: <br/>`alchemy-components/components/Component/Component.stories.tsx`
|
- Component stories are located in each component directory: <br/>`alchemy-components/components/Component/Component.stories.tsx`
|
||||||
|
|
||||||
Storybook serves as our playground for developing components. You can start it locally:
|
Storybook serves as our playground for developing components. You can start it locally:
|
||||||
|
|
||||||
@ -58,16 +58,16 @@ This launches the docs app at `localhost:6006` and enables everything you need t
|
|||||||
|
|
||||||
Building a component library is a collaboriate effort! We're aiming to provide a first-class experience, so here's a list of the standards we'll be looking for:
|
Building a component library is a collaboriate effort! We're aiming to provide a first-class experience, so here's a list of the standards we'll be looking for:
|
||||||
|
|
||||||
- Consitent prop and variant naming conventions: <br />
|
- Consitent prop and variant naming conventions: <br />
|
||||||
-- `variant` is used to define style types, such as `outline` or `filled`. <br />
|
-- `variant` is used to define style types, such as `outline` or `filled`. <br />
|
||||||
-- `color` is used to define the components color, such as `violet` or `blue`. <br />
|
-- `color` is used to define the components color, such as `violet` or `blue`. <br />
|
||||||
-- `size` is used to define the components size, such as `xs` or `4xl`. <br />
|
-- `size` is used to define the components size, such as `xs` or `4xl`. <br />
|
||||||
-- Booleans are prefixed with `is`: `isLoading` or `isDisabled`.
|
-- Booleans are prefixed with `is`: `isLoading` or `isDisabled`.
|
||||||
- All style props have a correseponding theme type, ie. `FontSizeOptions`.
|
- All style props have a correseponding theme type, ie. `FontSizeOptions`.
|
||||||
- All components have an export of default props.
|
- All components have an export of default props.
|
||||||
- Styles are defined using `style objects` instead of `tagged template literals`.
|
- Styles are defined using `style objects` instead of `tagged template literals`.
|
||||||
- Stories are organized into the correct directory .
|
- Stories are organized into the correct directory .
|
||||||
|
|
||||||
### FAQs
|
### FAQs
|
||||||
|
|
||||||
- **How are components being styled?** <br />Our components are built using [Styled Components](https://styled-components.com/) that dynamically generate styles based on variant selection.
|
- **How are components being styled?** <br />Our components are built using [Styled Components](https://styled-components.com/) that dynamically generate styles based on variant selection.
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import AutoComplete from './AutoComplete';
|
|
||||||
|
import AutoComplete from '@components/components/AutoComplete/AutoComplete';
|
||||||
|
|
||||||
// Auto Docs
|
// Auto Docs
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|||||||
@ -1,10 +1,15 @@
|
|||||||
import { AutoComplete as AntdAutoComplete } from 'antd';
|
import { AutoComplete as AntdAutoComplete } from 'antd';
|
||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
import ClickOutside from '../Utils/ClickOutside/ClickOutside';
|
|
||||||
import { DropdownWrapper } from './components';
|
import { DropdownWrapper } from '@components/components/AutoComplete/components';
|
||||||
import { AUTOCOMPLETE_WRAPPER_CLASS_CSS_SELECTOR, AUTOCOMPLETE_WRAPPER_CLASS_NAME, ESCAPE_KEY } from './constants';
|
import {
|
||||||
import { AutoCompleteProps, OptionType } from './types';
|
AUTOCOMPLETE_WRAPPER_CLASS_CSS_SELECTOR,
|
||||||
import { OverlayClassProvider } from '../Utils';
|
AUTOCOMPLETE_WRAPPER_CLASS_NAME,
|
||||||
|
ESCAPE_KEY,
|
||||||
|
} from '@components/components/AutoComplete/constants';
|
||||||
|
import { AutoCompleteProps, OptionType } from '@components/components/AutoComplete/types';
|
||||||
|
import { OverlayClassProvider } from '@components/components/Utils';
|
||||||
|
import ClickOutside from '@components/components/Utils/ClickOutside/ClickOutside';
|
||||||
|
|
||||||
export default function AutoComplete({
|
export default function AutoComplete({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
import AutoComplete from './AutoComplete';
|
import AutoComplete from '@components/components/AutoComplete/AutoComplete';
|
||||||
|
|
||||||
export { AutoComplete };
|
export { AutoComplete };
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
||||||
import { GridList } from '@src/alchemy-components/.docs/mdx-components';
|
|
||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Avatar, avatarDefaults } from './Avatar';
|
|
||||||
|
import { Avatar, avatarDefaults } from '@components/components/Avatar/Avatar';
|
||||||
|
|
||||||
|
import { GridList } from '@src/alchemy-components/.docs/mdx-components';
|
||||||
|
|
||||||
const IMAGE_URL =
|
const IMAGE_URL =
|
||||||
'https://is1-ssl.mzstatic.com/image/thumb/Purple211/v4/78/cb/e1/78cbe16d-28d9-057e-9f73-524c32eb5fe5/AppIcon-0-0-1x_U007emarketing-0-7-0-85-220.png/512x512bb.jpg';
|
'https://is1-ssl.mzstatic.com/image/thumb/Purple211/v4/78/cb/e1/78cbe16d-28d9-057e-9f73-524c32eb5fe5/AppIcon-0-0-1x_U007emarketing-0-7-0-85-220.png/512x512bb.jpg';
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { AvatarImage, AvatarImageWrapper, AvatarText, Container } from './components';
|
|
||||||
import { AvatarProps } from './types';
|
import { AvatarImage, AvatarImageWrapper, AvatarText, Container } from '@components/components/Avatar/components';
|
||||||
import getAvatarColor, { getNameInitials } from './utils';
|
import { AvatarProps } from '@components/components/Avatar/types';
|
||||||
|
import getAvatarColor, { getNameInitials } from '@components/components/Avatar/utils';
|
||||||
|
|
||||||
export const avatarDefaults: AvatarProps = {
|
export const avatarDefaults: AvatarProps = {
|
||||||
name: 'User name',
|
name: 'User name',
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { getNameInitials } from '../utils';
|
import { getNameInitials } from '@components/components/Avatar/utils';
|
||||||
|
|
||||||
describe('get initials of the name', () => {
|
describe('get initials of the name', () => {
|
||||||
it('get initials of name with first name and last name', () => {
|
it('get initials of name with first name and last name', () => {
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import { getAvatarColorStyles, getAvatarNameSizes, getAvatarSizes } from '@components/components/Avatar/utils';
|
||||||
|
|
||||||
import { colors } from '@src/alchemy-components/theme';
|
import { colors } from '@src/alchemy-components/theme';
|
||||||
import { AvatarSizeOptions } from '@src/alchemy-components/theme/config';
|
import { AvatarSizeOptions } from '@src/alchemy-components/theme/config';
|
||||||
import styled from 'styled-components';
|
|
||||||
import { getAvatarColorStyles, getAvatarNameSizes, getAvatarSizes } from './utils';
|
|
||||||
|
|
||||||
export const Container = styled.div<{ $hasOnClick: boolean; $showInPill?: boolean }>`
|
export const Container = styled.div<{ $hasOnClick: boolean; $showInPill?: boolean }>`
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
|
||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import { AvatarStack, avatarListDefaults } from './AvatarStack';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { AvatarStack, avatarListDefaults } from '@components/components/AvatarStack/AvatarStack';
|
||||||
|
|
||||||
// Meta Configuration
|
// Meta Configuration
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { AvatarContainer, AvatarStackContainer } from './components';
|
|
||||||
import { Avatar } from '../Avatar';
|
import { Avatar } from '@components/components/Avatar';
|
||||||
import { AvatarItemProps, AvatarStackProps } from './types';
|
import { AvatarContainer, AvatarStackContainer } from '@components/components/AvatarStack/components';
|
||||||
|
import { AvatarItemProps, AvatarStackProps } from '@components/components/AvatarStack/types';
|
||||||
|
|
||||||
export const avatarListDefaults: AvatarStackProps = {
|
export const avatarListDefaults: AvatarStackProps = {
|
||||||
avatars: [
|
avatars: [
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
import React from 'react';
|
|
||||||
|
|
||||||
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
import { GridList } from '@components/.docs/mdx-components';
|
import { GridList } from '@components/.docs/mdx-components';
|
||||||
import { Badge, badgeDefault } from './Badge';
|
import { Badge, badgeDefault } from '@components/components/Badge/Badge';
|
||||||
import pillMeta from '../Pills/Pill.stories';
|
import { omitKeys } from '@components/components/Badge/utils';
|
||||||
import { omitKeys } from './utils';
|
import pillMeta from '@components/components/Pills/Pill.stories';
|
||||||
|
|
||||||
const pillMetaArgTypes = omitKeys(pillMeta.argTypes, ['label']);
|
const pillMetaArgTypes = omitKeys(pillMeta.argTypes, ['label']);
|
||||||
const pillMetaArgs = omitKeys(pillMeta.args, ['label']);
|
const pillMetaArgs = omitKeys(pillMeta.args, ['label']);
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { Pill } from '@components';
|
import { Pill } from '@components';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
|
|
||||||
import { BadgeProps } from './types';
|
import { BadgeContainer } from '@components/components/Badge/components';
|
||||||
import { formatBadgeValue } from './utils';
|
import { BadgeProps } from '@components/components/Badge/types';
|
||||||
import { BadgeContainer } from './components';
|
import { formatBadgeValue } from '@components/components/Badge/utils';
|
||||||
|
|
||||||
export const badgeDefault: BadgeProps = {
|
export const badgeDefault: BadgeProps = {
|
||||||
count: 0,
|
count: 0,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { HTMLAttributes } from 'react';
|
import { HTMLAttributes } from 'react';
|
||||||
import { PillProps } from '../Pills/types';
|
|
||||||
|
import { PillProps } from '@components/components/Pills/types';
|
||||||
|
|
||||||
export interface BadgeProps extends Omit<PillProps, 'label'>, Omit<HTMLAttributes<HTMLElement>, 'color'> {
|
export interface BadgeProps extends Omit<PillProps, 'label'>, Omit<HTMLAttributes<HTMLElement>, 'color'> {
|
||||||
count: number;
|
count: number;
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import React from 'react';
|
|
||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import colors from '@src/alchemy-components/theme/foundations/colors';
|
import React from 'react';
|
||||||
|
|
||||||
import { Bar } from './Bar';
|
import { Bar } from '@components/components/Bar/Bar';
|
||||||
|
|
||||||
|
import colors from '@src/alchemy-components/theme/foundations/colors';
|
||||||
|
|
||||||
const meta: Meta<typeof Bar> = {
|
const meta: Meta<typeof Bar> = {
|
||||||
title: 'Components / Bar',
|
title: 'Components / Bar',
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { colors } from '@src/alchemy-components/theme';
|
|
||||||
|
|
||||||
import { BarComponentProps } from './types';
|
import { BarContainer, IndividualBar } from '@components/components/Bar/components';
|
||||||
import { BarContainer, IndividualBar } from './components';
|
import { BAR_HEIGHT_MULTIPLIER } from '@components/components/Bar/constant';
|
||||||
import { BAR_HEIGHT_MULTIPLIER } from './constant';
|
import { BarComponentProps } from '@components/components/Bar/types';
|
||||||
|
|
||||||
|
import { colors } from '@src/alchemy-components/theme';
|
||||||
|
|
||||||
const defaultProps: BarComponentProps = {
|
const defaultProps: BarComponentProps = {
|
||||||
color: colors.violet[500],
|
color: colors.violet[500],
|
||||||
|
|||||||
@ -11,5 +11,7 @@ export const IndividualBar = styled.div<{ height: number; isColored: boolean; co
|
|||||||
height: ${(props) => props.height}px;
|
height: ${(props) => props.height}px;
|
||||||
background-color: ${(props) => (props.isColored ? props.color : '#C6C0E0')};
|
background-color: ${(props) => (props.isColored ? props.color : '#C6C0E0')};
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
transition: background-color 0.3s ease, height 0.3s ease;
|
transition:
|
||||||
|
background-color 0.3s ease,
|
||||||
|
height 0.3s ease;
|
||||||
`;
|
`;
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
import React from 'react';
|
|
||||||
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
import { BarChart } from './BarChart';
|
import React from 'react';
|
||||||
import { generateMockDataHorizontal, getMockedProps } from './utils';
|
|
||||||
import { DEFAULT_MIN_VALUE } from './hooks/usePrepareAccessors';
|
import { BarChart } from '@components/components/BarChart/BarChart';
|
||||||
import { DEFAULT_MAX_DOMAIN_VALUE } from './hooks/usePrepareScales';
|
import { DEFAULT_LENGTH_OF_LEFT_AXIS_LABEL } from '@components/components/BarChart/constants';
|
||||||
import { abbreviateNumber } from '../dataviz/utils';
|
import { DEFAULT_MIN_VALUE } from '@components/components/BarChart/hooks/usePrepareAccessors';
|
||||||
import { DEFAULT_LENGTH_OF_LEFT_AXIS_LABEL } from './constants';
|
import { DEFAULT_MAX_DOMAIN_VALUE } from '@components/components/BarChart/hooks/usePrepareScales';
|
||||||
|
import { generateMockDataHorizontal, getMockedProps } from '@components/components/BarChart/utils';
|
||||||
|
import { abbreviateNumber } from '@components/components/dataviz/utils';
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
title: 'Charts / BarChart',
|
title: 'Charts / BarChart',
|
||||||
|
|||||||
@ -1,20 +1,30 @@
|
|||||||
import React, { useCallback, useMemo, useState } from 'react';
|
|
||||||
import { colors } from '@src/alchemy-components/theme';
|
|
||||||
import { LinearGradient } from '@visx/gradient';
|
import { LinearGradient } from '@visx/gradient';
|
||||||
import { ParentSize } from '@visx/responsive';
|
import { ParentSize } from '@visx/responsive';
|
||||||
import { Axis, AxisScale, BarSeries, Grid, Tooltip, XYChart } from '@visx/xychart';
|
import { Axis, AxisScale, BarSeries, Grid, Tooltip, XYChart } from '@visx/xychart';
|
||||||
import { Popover } from '../Popover';
|
import React, { useCallback, useMemo, useState } from 'react';
|
||||||
import { ChartWrapper, StyledBarSeries } from './components';
|
|
||||||
import { AxisProps, BarChartProps, ColorAccessor, Datum, GridProps, XAccessor, YAccessor } from './types';
|
import { ChartWrapper, StyledBarSeries } from '@components/components/BarChart/components';
|
||||||
import { getMockedProps } from './utils';
|
import LeftAxisMarginSetter from '@components/components/BarChart/components/LeftAxisMarginSetter';
|
||||||
import useMergedProps from './hooks/useMergedProps';
|
import TruncatableTick from '@components/components/BarChart/components/TruncatableTick';
|
||||||
import usePrepareScales from './hooks/usePrepareScales';
|
import { COLOR_SCHEME_TO_PARAMS, DEFAULT_COLOR_SCHEME } from '@components/components/BarChart/constants';
|
||||||
import usePrepareAccessors from './hooks/usePrepareAccessors';
|
import { barChartDefault } from '@components/components/BarChart/defaults';
|
||||||
import { COLOR_SCHEME_TO_PARAMS, DEFAULT_COLOR_SCHEME } from './constants';
|
import useMergedProps from '@components/components/BarChart/hooks/useMergedProps';
|
||||||
import TruncatableTick from './components/TruncatableTick';
|
import usePrepareAccessors from '@components/components/BarChart/hooks/usePrepareAccessors';
|
||||||
import { barChartDefault } from './defaults';
|
import usePrepareScales from '@components/components/BarChart/hooks/usePrepareScales';
|
||||||
import LeftAxisMarginSetter from './components/LeftAxisMarginSetter';
|
import {
|
||||||
import { abbreviateNumber } from '../dataviz/utils';
|
AxisProps,
|
||||||
|
BarChartProps,
|
||||||
|
ColorAccessor,
|
||||||
|
Datum,
|
||||||
|
GridProps,
|
||||||
|
XAccessor,
|
||||||
|
YAccessor,
|
||||||
|
} from '@components/components/BarChart/types';
|
||||||
|
import { getMockedProps } from '@components/components/BarChart/utils';
|
||||||
|
import { Popover } from '@components/components/Popover';
|
||||||
|
import { abbreviateNumber } from '@components/components/dataviz/utils';
|
||||||
|
|
||||||
|
import { colors } from '@src/alchemy-components/theme';
|
||||||
|
|
||||||
export function BarChart({
|
export function BarChart({
|
||||||
data,
|
data,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
|
import { TickFormatter } from '@visx/axis';
|
||||||
|
import { getTicks } from '@visx/scale';
|
||||||
import { DataContext } from '@visx/xychart';
|
import { DataContext } from '@visx/xychart';
|
||||||
import { useCallback, useContext, useEffect } from 'react';
|
import { useCallback, useContext, useEffect } from 'react';
|
||||||
import { getTicks } from '@visx/scale';
|
|
||||||
import { TickFormatter } from '@visx/axis';
|
|
||||||
|
|
||||||
interface LeftAxisMarginSetterProps {
|
interface LeftAxisMarginSetterProps {
|
||||||
setLeftMargin?: (margin: number) => void;
|
setLeftMargin?: (margin: number) => void;
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import React from 'react';
|
|
||||||
import { Text } from '@visx/text';
|
import { Text } from '@visx/text';
|
||||||
import { Popover } from '../../Popover';
|
import React from 'react';
|
||||||
import { TruncatableTickProps } from '../types';
|
|
||||||
|
import { TruncatableTickProps } from '@components/components/BarChart/types';
|
||||||
|
import { Popover } from '@components/components/Popover';
|
||||||
|
|
||||||
export default function TruncatableTick({ formattedValue, limit, ...textProps }: TruncatableTickProps) {
|
export default function TruncatableTick({ formattedValue, limit, ...textProps }: TruncatableTickProps) {
|
||||||
if (formattedValue === undefined) return null;
|
if (formattedValue === undefined) return null;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
|
import { ColorScheme, ColorSchemeParams } from '@components/components/BarChart/types';
|
||||||
|
|
||||||
import { colors } from '@src/alchemy-components/theme';
|
import { colors } from '@src/alchemy-components/theme';
|
||||||
import { ColorScheme, ColorSchemeParams } from './types';
|
|
||||||
|
|
||||||
export const VIOLET_COLOR_SCHEME_PRARAMS: ColorSchemeParams = {
|
export const VIOLET_COLOR_SCHEME_PRARAMS: ColorSchemeParams = {
|
||||||
mainColor: colors.violet[500],
|
mainColor: colors.violet[500],
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import { colors } from '@src/alchemy-components/theme';
|
|
||||||
import { TickLabelProps } from '@visx/axis';
|
import { TickLabelProps } from '@visx/axis';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { DEFAULT_LENGTH_OF_LEFT_AXIS_LABEL } from './constants';
|
|
||||||
import { BarChartProps, Datum } from './types';
|
import { DEFAULT_LENGTH_OF_LEFT_AXIS_LABEL } from '@components/components/BarChart/constants';
|
||||||
import { abbreviateNumber } from '../dataviz/utils';
|
import { BarChartProps, Datum } from '@components/components/BarChart/types';
|
||||||
|
import { abbreviateNumber } from '@components/components/dataviz/utils';
|
||||||
|
|
||||||
|
import { colors } from '@src/alchemy-components/theme';
|
||||||
|
|
||||||
const commonTickLabelProps: TickLabelProps<Datum> = {
|
const commonTickLabelProps: TickLabelProps<Datum> = {
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { BaseDatum, YAccessor } from '../types';
|
|
||||||
|
import { BaseDatum, YAccessor } from '@components/components/BarChart/types';
|
||||||
|
|
||||||
export default function useMaxDataValue(data: BaseDatum[], yAccessor: YAccessor): number {
|
export default function useMaxDataValue(data: BaseDatum[], yAccessor: YAccessor): number {
|
||||||
return useMemo(() => Math.max(...data.map(yAccessor)) ?? 0, [data, yAccessor]);
|
return useMemo(() => Math.max(...data.map(yAccessor)) ?? 0, [data, yAccessor]);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { BaseDatum, YAccessor } from '../types';
|
|
||||||
|
import { BaseDatum, YAccessor } from '@components/components/BarChart/types';
|
||||||
|
|
||||||
export default function useMinDataValue(data: BaseDatum[], yAccessor: YAccessor): number {
|
export default function useMinDataValue(data: BaseDatum[], yAccessor: YAccessor): number {
|
||||||
return useMemo(() => Math.min(...data.map(yAccessor)) ?? 0, [data, yAccessor]);
|
return useMemo(() => Math.min(...data.map(yAccessor)) ?? 0, [data, yAccessor]);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { BaseDatum, XAccessor, YAccessor } from '../types';
|
|
||||||
|
import { BaseDatum, XAccessor, YAccessor } from '@components/components/BarChart/types';
|
||||||
|
|
||||||
export const DEFAULT_MIN_VALUE = 0.1;
|
export const DEFAULT_MIN_VALUE = 0.1;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { BaseDatum, Scale, XAccessor, YAccessor } from '../types';
|
|
||||||
|
import { BaseDatum, Scale, XAccessor, YAccessor } from '@components/components/BarChart/types';
|
||||||
|
|
||||||
export const DEFAULT_MAX_DOMAIN_VALUE = 10;
|
export const DEFAULT_MAX_DOMAIN_VALUE = 10;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { COLOR_SCHEMES } from './constants';
|
|
||||||
|
import { COLOR_SCHEMES } from '@components/components/BarChart/constants';
|
||||||
|
|
||||||
export function generateMockData(length = 30, maxValue = 50_000, minValue = 0) {
|
export function generateMockData(length = 30, maxValue = 50_000, minValue = 0) {
|
||||||
return Array(length)
|
return Array(length)
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
|
import { AVAILABLE_ICONS } from '@components';
|
||||||
|
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { GridList } from '@components/.docs/mdx-components';
|
||||||
import { ButtonVariantValues } from '@components/components/Button/types';
|
import { ButtonVariantValues } from '@components/components/Button/types';
|
||||||
import { MATERIAL_UI_ICONS, PHOSPHOR_ICONS } from '@components/components/Icon/constants';
|
import { MATERIAL_UI_ICONS, PHOSPHOR_ICONS } from '@components/components/Icon/constants';
|
||||||
import { SizeValues } from '@components/theme/config';
|
import { SizeValues } from '@components/theme/config';
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
|
||||||
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
|
||||||
|
|
||||||
import { GridList } from '@components/.docs/mdx-components';
|
|
||||||
import { AVAILABLE_ICONS } from '@components';
|
|
||||||
|
|
||||||
import { Button, buttonDefaults } from '.';
|
import { Button, buttonDefaults } from '.';
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
|
import { LoadingOutlined } from '@ant-design/icons';
|
||||||
|
import { Icon } from '@components';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { LoadingOutlined } from '@ant-design/icons';
|
import { ButtonBase } from '@components/components/Button/components';
|
||||||
|
import { ButtonProps, ButtonPropsDefaults } from '@components/components/Button/types';
|
||||||
import { Icon } from '@components';
|
|
||||||
|
|
||||||
import { ButtonBase } from './components';
|
|
||||||
import { ButtonProps, ButtonPropsDefaults } from './types';
|
|
||||||
|
|
||||||
export const buttonDefaults: ButtonPropsDefaults = {
|
export const buttonDefaults: ButtonPropsDefaults = {
|
||||||
variant: 'filled',
|
variant: 'filled',
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import { ButtonStyleProps } from '@components/components/Button/types';
|
||||||
|
import { getButtonStyle } from '@components/components/Button/utils';
|
||||||
import { spacing } from '@components/theme';
|
import { spacing } from '@components/theme';
|
||||||
import { ButtonStyleProps } from './types';
|
|
||||||
import { getButtonStyle } from './utils';
|
|
||||||
|
|
||||||
export const ButtonBase = styled.button(
|
export const ButtonBase = styled.button(
|
||||||
// Dynamic styles
|
// Dynamic styles
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { IconProps } from '@components/components/Icon/types';
|
|
||||||
import { ButtonHTMLAttributes } from 'react';
|
import { ButtonHTMLAttributes } from 'react';
|
||||||
|
|
||||||
import type { SizeOptions, ColorOptions } from '@components/theme/config';
|
import { IconProps } from '@components/components/Icon/types';
|
||||||
|
import type { ColorOptions, SizeOptions } from '@components/theme/config';
|
||||||
|
|
||||||
export enum ButtonVariantValues {
|
export enum ButtonVariantValues {
|
||||||
filled = 'filled',
|
filled = 'filled',
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Button Style Utilities
|
* Button Style Utilities
|
||||||
*/
|
*/
|
||||||
|
import { CSSObject } from 'styled-components';
|
||||||
|
|
||||||
import { typography, colors, shadows, radius, spacing } from '@components/theme';
|
import { ButtonStyleProps, ButtonVariant } from '@components/components/Button/types';
|
||||||
|
import { colors, radius, shadows, spacing, typography } from '@components/theme';
|
||||||
import { ColorOptions, SizeOptions } from '@components/theme/config';
|
import { ColorOptions, SizeOptions } from '@components/theme/config';
|
||||||
import { getColor, getFontSize } from '@components/theme/utils';
|
import { getColor, getFontSize } from '@components/theme/utils';
|
||||||
import { CSSObject } from 'styled-components';
|
|
||||||
import { ButtonStyleProps, ButtonVariant } from './types';
|
|
||||||
|
|
||||||
interface ColorStyles {
|
interface ColorStyles {
|
||||||
bgColor: string;
|
bgColor: string;
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import React from 'react';
|
|
||||||
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
import { CalendarChart } from './CalendarChart';
|
import React from 'react';
|
||||||
import { getMockedProps } from './utils';
|
|
||||||
|
import { CalendarChart } from '@components/components/CalendarChart/CalendarChart';
|
||||||
|
import { getMockedProps } from '@components/components/CalendarChart/utils';
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
title: 'Charts / CalendarChart',
|
title: 'Charts / CalendarChart',
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
import { colors } from '@src/alchemy-components/theme';
|
|
||||||
import { ParentSize } from '@visx/responsive';
|
import { ParentSize } from '@visx/responsive';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { ChartWrapper } from './components';
|
|
||||||
import { AxisBottomMonths } from './private/components/AxisBottomMonths';
|
import { ChartWrapper } from '@components/components/CalendarChart/components';
|
||||||
import { AxisLeftWeekdays } from './private/components/AxisLeftWeekdays';
|
import { AxisBottomMonths } from '@components/components/CalendarChart/private/components/AxisBottomMonths';
|
||||||
import { Calendar } from './private/components/Calendar';
|
import { AxisLeftWeekdays } from '@components/components/CalendarChart/private/components/AxisLeftWeekdays';
|
||||||
import { CalendarProvider } from './private/context';
|
import { Calendar } from '@components/components/CalendarChart/private/components/Calendar';
|
||||||
import { CalendarChartProps } from './types';
|
import { CalendarContainer } from '@components/components/CalendarChart/private/components/CalendarContainer';
|
||||||
import { prepareCalendarData } from './utils';
|
import { CalendarProvider } from '@components/components/CalendarChart/private/context';
|
||||||
import { CalendarContainer } from './private/components/CalendarContainer';
|
import { CalendarChartProps } from '@components/components/CalendarChart/types';
|
||||||
|
import { prepareCalendarData } from '@components/components/CalendarChart/utils';
|
||||||
|
|
||||||
|
import { colors } from '@src/alchemy-components/theme';
|
||||||
|
|
||||||
const commonLabelProps = {
|
const commonLabelProps = {
|
||||||
fill: colors.gray[1700],
|
fill: colors.gray[1700],
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { CalendarData } from '../types';
|
import { CalendarData } from '@components/components/CalendarChart/types';
|
||||||
import { getColorAccessor } from '../utils';
|
import { getColorAccessor } from '@components/components/CalendarChart/utils';
|
||||||
|
|
||||||
type Datum = {
|
type Datum = {
|
||||||
value1: number;
|
value1: number;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { CalendarData } from '../types';
|
import { CalendarData } from '@components/components/CalendarChart/types';
|
||||||
import { prepareCalendarData } from '../utils';
|
import { prepareCalendarData } from '@components/components/CalendarChart/utils';
|
||||||
|
|
||||||
const sampleData: CalendarData<number>[] = [
|
const sampleData: CalendarData<number>[] = [
|
||||||
{ day: '2024-12-02', value: 1 },
|
{ day: '2024-12-02', value: 1 },
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DAYS_IN_WEEK } from '../constants';
|
|
||||||
import { useCalendarState } from '../context';
|
import { TickLabel } from '@components/components/CalendarChart/private/components/TickLabel';
|
||||||
import { TickLabel } from './TickLabel';
|
import { DAYS_IN_WEEK } from '@components/components/CalendarChart/private/constants';
|
||||||
import { AxisBottomMonthsProps } from '../../types';
|
import { useCalendarState } from '@components/components/CalendarChart/private/context';
|
||||||
|
import { AxisBottomMonthsProps } from '@components/components/CalendarChart/types';
|
||||||
|
|
||||||
export function AxisBottomMonths<ValueType>({ labelProps }: AxisBottomMonthsProps) {
|
export function AxisBottomMonths<ValueType>({ labelProps }: AxisBottomMonthsProps) {
|
||||||
const { squareSize, squareGap, margin, data } = useCalendarState<ValueType>();
|
const { squareSize, squareGap, margin, data } = useCalendarState<ValueType>();
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DAYS_IN_WEEK } from '../constants';
|
|
||||||
import { AxisLeftWeekdaysProps } from '../../types';
|
import { TickLabel } from '@components/components/CalendarChart/private/components/TickLabel';
|
||||||
import { useCalendarState } from '../context';
|
import { DAYS_IN_WEEK } from '@components/components/CalendarChart/private/constants';
|
||||||
import { TickLabel } from './TickLabel';
|
import { useCalendarState } from '@components/components/CalendarChart/private/context';
|
||||||
|
import { AxisLeftWeekdaysProps } from '@components/components/CalendarChart/types';
|
||||||
|
|
||||||
const WEEKDAYS = ['Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun'];
|
const WEEKDAYS = ['Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun'];
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { CalendarProps } from '../../types';
|
|
||||||
import { Month } from './Month';
|
import { Month } from '@components/components/CalendarChart/private/components/Month';
|
||||||
|
import { CalendarProps } from '@components/components/CalendarChart/types';
|
||||||
|
|
||||||
export function Calendar<ValueType>({ data }: CalendarProps<ValueType>) {
|
export function Calendar<ValueType>({ data }: CalendarProps<ValueType>) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { useCalendarState } from '../context';
|
|
||||||
import { DAYS_IN_WEEK } from '../constants';
|
import { CalendarInnerWrapper, CalendarWrapper } from '@components/components/CalendarChart/components';
|
||||||
import { CalendarContainerProps } from '../../types';
|
import { DAYS_IN_WEEK } from '@components/components/CalendarChart/private/constants';
|
||||||
import { CalendarInnerWrapper, CalendarWrapper } from '../../components';
|
import { useCalendarState } from '@components/components/CalendarChart/private/context';
|
||||||
|
import { CalendarContainerProps } from '@components/components/CalendarChart/types';
|
||||||
|
|
||||||
export function CalendarContainer<ValueType>({ children }: CalendarContainerProps) {
|
export function CalendarContainer<ValueType>({ children }: CalendarContainerProps) {
|
||||||
const { squareSize, squareGap, margin, parentHeight, countOfWeeks, countOfMonths } = useCalendarState<ValueType>();
|
const { squareSize, squareGap, margin, parentHeight, countOfWeeks, countOfMonths } = useCalendarState<ValueType>();
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
import { Popover } from '@src/alchemy-components/components/Popover';
|
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { DayProps } from '../../types';
|
|
||||||
import { useCalendarState } from '../context';
|
import { StyledBar } from '@components/components/CalendarChart/components';
|
||||||
import { StyledBar } from '../../components';
|
import { useCalendarState } from '@components/components/CalendarChart/private/context';
|
||||||
|
import { DayProps } from '@components/components/CalendarChart/types';
|
||||||
|
|
||||||
|
import { Popover } from '@src/alchemy-components/components/Popover';
|
||||||
|
|
||||||
export function Day<ValueType>({ day, weekOffset, dayIndex }: DayProps<ValueType>) {
|
export function Day<ValueType>({ day, weekOffset, dayIndex }: DayProps<ValueType>) {
|
||||||
const { squareSize, squareGap, margin, colorAccessor, showPopover, popoverRenderer, selectedDay, onDayClick } =
|
const { squareSize, squareGap, margin, colorAccessor, showPopover, popoverRenderer, selectedDay, onDayClick } =
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { MonthProps } from '../../types';
|
|
||||||
import { useCalendarState } from '../context';
|
import { Week } from '@components/components/CalendarChart/private/components/Week';
|
||||||
import { Week } from './Week';
|
import { useCalendarState } from '@components/components/CalendarChart/private/context';
|
||||||
|
import { MonthProps } from '@components/components/CalendarChart/types';
|
||||||
|
|
||||||
export function Month<ValueType>({ month, monthIndex }: MonthProps<ValueType>) {
|
export function Month<ValueType>({ month, monthIndex }: MonthProps<ValueType>) {
|
||||||
const { squareGap, data } = useCalendarState();
|
const { squareGap, data } = useCalendarState();
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { WeekProps } from '../../types';
|
|
||||||
import { useCalendarState } from '../context';
|
import { Day } from '@components/components/CalendarChart/private/components/Day';
|
||||||
import { Day } from './Day';
|
import { useCalendarState } from '@components/components/CalendarChart/private/context';
|
||||||
|
import { WeekProps } from '@components/components/CalendarChart/types';
|
||||||
|
|
||||||
export function Week<ValueType>({ week, weekNumber, monthOffset }: WeekProps<ValueType>) {
|
export function Week<ValueType>({ week, weekNumber, monthOffset }: WeekProps<ValueType>) {
|
||||||
const { squareSize, squareGap, margin } = useCalendarState<ValueType>();
|
const { squareSize, squareGap, margin } = useCalendarState<ValueType>();
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { Margin } from '@visx/xychart';
|
import { Margin } from '@visx/xychart';
|
||||||
import React, { createContext, PropsWithChildren, useContext, useMemo } from 'react';
|
import React, { PropsWithChildren, createContext, useContext, useMemo } from 'react';
|
||||||
import { DayData, MonthData } from '../types';
|
|
||||||
import { DAYS_IN_WEEK, MIN_GAP_SIZE, MIN_SQUARE_SIZE } from './constants';
|
import { DAYS_IN_WEEK, MIN_GAP_SIZE, MIN_SQUARE_SIZE } from '@components/components/CalendarChart/private/constants';
|
||||||
|
import { DayData, MonthData } from '@components/components/CalendarChart/types';
|
||||||
|
|
||||||
export type CalendarContextState<ValueType = any> = {
|
export type CalendarContextState<ValueType = any> = {
|
||||||
data: MonthData<ValueType>[];
|
data: MonthData<ValueType>[];
|
||||||
|
|||||||
@ -1,12 +1,20 @@
|
|||||||
import { scaleLinear } from '@visx/scale';
|
import { scaleLinear } from '@visx/scale';
|
||||||
import * as d3interpolate from '@visx/vendor/d3-interpolate';
|
import * as d3interpolate from '@visx/vendor/d3-interpolate';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
||||||
import isoWeek from 'dayjs/plugin/isoWeek';
|
import isoWeek from 'dayjs/plugin/isoWeek';
|
||||||
import utc from 'dayjs/plugin/utc';
|
import utc from 'dayjs/plugin/utc';
|
||||||
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
||||||
import { CalendarChartProps, CalendarData, ColorAccessor, DayData, MonthData, WeekData } from './types';
|
import { CALENDAR_DATE_FORMAT } from '@components/components/CalendarChart/constants';
|
||||||
import { DAYS_IN_WEEK, MIN_DAYS_IN_WEEK } from './private/constants';
|
import { DAYS_IN_WEEK, MIN_DAYS_IN_WEEK } from '@components/components/CalendarChart/private/constants';
|
||||||
import { CALENDAR_DATE_FORMAT } from './constants';
|
import {
|
||||||
|
CalendarChartProps,
|
||||||
|
CalendarData,
|
||||||
|
ColorAccessor,
|
||||||
|
DayData,
|
||||||
|
MonthData,
|
||||||
|
WeekData,
|
||||||
|
} from '@components/components/CalendarChart/types';
|
||||||
|
|
||||||
dayjs.extend(isoWeek);
|
dayjs.extend(isoWeek);
|
||||||
dayjs.extend(utc);
|
dayjs.extend(utc);
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
||||||
import { GridList } from '@src/alchemy-components/.docs/mdx-components';
|
|
||||||
import { colors } from '@src/alchemy-components/theme';
|
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { Icon } from '@components/components/Icon';
|
||||||
|
|
||||||
|
import { GridList } from '@src/alchemy-components/.docs/mdx-components';
|
||||||
|
import { colors } from '@src/alchemy-components/theme';
|
||||||
|
|
||||||
import { Card, cardDefaults } from '.';
|
import { Card, cardDefaults } from '.';
|
||||||
import { Icon } from '../Icon';
|
|
||||||
|
|
||||||
// Auto Docs
|
// Auto Docs
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|||||||
@ -1,7 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { CardProps } from './types';
|
|
||||||
import { CardContainer, Header, SubTitle, SubTitleContainer, Title, TitleContainer } from './components';
|
import {
|
||||||
import { Pill } from '../Pills';
|
CardContainer,
|
||||||
|
Header,
|
||||||
|
SubTitle,
|
||||||
|
SubTitleContainer,
|
||||||
|
Title,
|
||||||
|
TitleContainer,
|
||||||
|
} from '@components/components/Card/components';
|
||||||
|
import { CardProps } from '@components/components/Card/types';
|
||||||
|
import { Pill } from '@components/components/Pills';
|
||||||
|
|
||||||
export const cardDefaults: CardProps = {
|
export const cardDefaults: CardProps = {
|
||||||
title: 'Title',
|
title: 'Title',
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { colors, radius, spacing, typography } from '@src/alchemy-components/theme';
|
import { colors, radius, spacing, typography } from '@src/alchemy-components/theme';
|
||||||
import { IconAlignmentOptions } from '@src/alchemy-components/theme/config';
|
import { IconAlignmentOptions } from '@src/alchemy-components/theme/config';
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
export const CardContainer = styled.div<{ hasButton?: boolean; width?: string; maxWidth?: string; height?: string }>(
|
export const CardContainer = styled.div<{ hasButton?: boolean; width?: string; maxWidth?: string; height?: string }>(
|
||||||
({ hasButton, width, maxWidth, height }) => ({
|
({ hasButton, width, maxWidth, height }) => ({
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import React from 'react';
|
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
import { GridList } from '@components/.docs/mdx-components';
|
import { GridList } from '@components/.docs/mdx-components';
|
||||||
import { Checkbox, checkboxDefaults, CheckboxGroup } from './Checkbox';
|
import { Checkbox, CheckboxGroup, checkboxDefaults } from '@components/components/Checkbox/Checkbox';
|
||||||
import { CheckboxProps } from './types';
|
import { CheckboxProps } from '@components/components/Checkbox/types';
|
||||||
import { Heading } from '../Heading';
|
import { Heading } from '@components/components/Heading';
|
||||||
|
|
||||||
const MOCK_CHECKBOXES: CheckboxProps[] = [
|
const MOCK_CHECKBOXES: CheckboxProps[] = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { CheckboxProps, CheckboxGroupProps } from './types';
|
|
||||||
import {
|
import {
|
||||||
CheckboxBase,
|
CheckboxBase,
|
||||||
CheckboxContainer,
|
CheckboxContainer,
|
||||||
@ -9,7 +9,8 @@ import {
|
|||||||
Label,
|
Label,
|
||||||
Required,
|
Required,
|
||||||
StyledCheckbox,
|
StyledCheckbox,
|
||||||
} from './components';
|
} from '@components/components/Checkbox/components';
|
||||||
|
import { CheckboxGroupProps, CheckboxProps } from '@components/components/Checkbox/types';
|
||||||
|
|
||||||
export const checkboxDefaults: CheckboxProps = {
|
export const checkboxDefaults: CheckboxProps = {
|
||||||
error: '',
|
error: '',
|
||||||
|
|||||||
@ -1,8 +1,14 @@
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { borders, colors, spacing, transform, zIndices, radius } from '@components/theme';
|
|
||||||
|
import {
|
||||||
|
getCheckboxColor,
|
||||||
|
getCheckboxHoverBackgroundColor,
|
||||||
|
getCheckboxSize,
|
||||||
|
} from '@components/components/Checkbox/utils';
|
||||||
|
import { formLabelTextStyles } from '@components/components/commonStyles';
|
||||||
|
import { borders, colors, radius, spacing, transform, zIndices } from '@components/theme';
|
||||||
|
|
||||||
import { SizeOptions } from '@src/alchemy-components/theme/config';
|
import { SizeOptions } from '@src/alchemy-components/theme/config';
|
||||||
import { getCheckboxColor, getCheckboxHoverBackgroundColor, getCheckboxSize } from './utils';
|
|
||||||
import { formLabelTextStyles } from '../commonStyles';
|
|
||||||
|
|
||||||
export const CheckboxContainer = styled.div({
|
export const CheckboxContainer = styled.div({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { InputHTMLAttributes } from 'react';
|
import { InputHTMLAttributes } from 'react';
|
||||||
|
|
||||||
import { SizeOptions } from '@src/alchemy-components/theme/config';
|
import { SizeOptions } from '@src/alchemy-components/theme/config';
|
||||||
|
|
||||||
export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import theme, { colors } from '@components/theme';
|
import theme, { colors } from '@components/theme';
|
||||||
|
|
||||||
import { SizeOptions } from '@src/alchemy-components/theme/config';
|
import { SizeOptions } from '@src/alchemy-components/theme/config';
|
||||||
|
|
||||||
const checkboxBackgroundDefault = {
|
const checkboxBackgroundDefault = {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useEffect, useCallback } from 'react';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
import { CirclePicker, ColorResult } from 'react-color';
|
|
||||||
import { Input, colors } from '@components';
|
import { Input, colors } from '@components';
|
||||||
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
|
import { CirclePicker, ColorResult } from 'react-color';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const DEFAULT_COLORS = [
|
const DEFAULT_COLORS = [
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { DatePicker, datePickerDefault } from './DatePicker';
|
|
||||||
import { DatePickerValue } from './types';
|
import { DatePicker, datePickerDefault } from '@components/components/DatePicker/DatePicker';
|
||||||
|
import { DatePickerValue } from '@components/components/DatePicker/types';
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
title: 'Forms / DatePicker',
|
title: 'Forms / DatePicker',
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import React, { useEffect, useMemo, useState } from 'react';
|
||||||
import { StyledAntdDatePicker } from './components';
|
|
||||||
import useVariantProps from './hooks/useVariantProps';
|
import { StyledAntdDatePicker } from '@components/components/DatePicker/components';
|
||||||
import { DatePickerVariant } from './constants';
|
import { DatePickerVariant } from '@components/components/DatePicker/constants';
|
||||||
import { DatePickerProps, DatePickerValue } from './types';
|
import useVariantProps from '@components/components/DatePicker/hooks/useVariantProps';
|
||||||
|
import { DatePickerProps, DatePickerValue } from '@components/components/DatePicker/types';
|
||||||
|
|
||||||
export const datePickerDefault: DatePickerProps = {
|
export const datePickerDefault: DatePickerProps = {
|
||||||
variant: DatePickerVariant.Default,
|
variant: DatePickerVariant.Default,
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { colors } from '@src/alchemy-components/theme';
|
|
||||||
import { DatePicker as AntdDatePicker } from 'antd';
|
import { DatePicker as AntdDatePicker } from 'antd';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import { colors } from '@src/alchemy-components/theme';
|
||||||
|
|
||||||
export const StyledAntdDatePicker = styled(AntdDatePicker)<{ $noDefaultPaddings?: boolean }>`
|
export const StyledAntdDatePicker = styled(AntdDatePicker)<{ $noDefaultPaddings?: boolean }>`
|
||||||
&.ant-picker {
|
&.ant-picker {
|
||||||
${(props) => props.$noDefaultPaddings && 'padding: 0;'}
|
${(props) => props.$noDefaultPaddings && 'padding: 0;'}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { DatePickerVariant } from '../constants';
|
|
||||||
import { VariantProps } from '../types';
|
import { DatePickerVariant } from '@components/components/DatePicker/constants';
|
||||||
import { CommonVariantProps, DateSwitcherVariantProps } from '../variants';
|
import { VariantProps } from '@components/components/DatePicker/types';
|
||||||
|
import { CommonVariantProps, DateSwitcherVariantProps } from '@components/components/DatePicker/variants';
|
||||||
|
|
||||||
export default function useVariantProps(variant: DatePickerVariant | undefined): VariantProps {
|
export default function useVariantProps(variant: DatePickerVariant | undefined): VariantProps {
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { DatePicker as AntdDatePicker } from 'antd';
|
import { DatePicker as AntdDatePicker } from 'antd';
|
||||||
import { Moment } from 'moment';
|
import { Moment } from 'moment';
|
||||||
import { DatePickerVariant } from './constants';
|
|
||||||
|
import { DatePickerVariant } from '@components/components/DatePicker/constants';
|
||||||
|
|
||||||
export type DatePickerProps = {
|
export type DatePickerProps = {
|
||||||
value?: DatePickerValue;
|
value?: DatePickerValue;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { StyledCalendarWrapper } from '../../components';
|
|
||||||
import { VariantProps } from '../../types';
|
import { StyledCalendarWrapper } from '@components/components/DatePicker/components';
|
||||||
|
import { VariantProps } from '@components/components/DatePicker/types';
|
||||||
|
|
||||||
export const CommonVariantProps: VariantProps = {
|
export const CommonVariantProps: VariantProps = {
|
||||||
panelRender: (panel) => <StyledCalendarWrapper>{panel}</StyledCalendarWrapper>,
|
panelRender: (panel) => <StyledCalendarWrapper>{panel}</StyledCalendarWrapper>,
|
||||||
|
|||||||
@ -2,9 +2,10 @@ import { colors } from '@components';
|
|||||||
import { CaretLeft, CaretRight } from 'phosphor-react';
|
import { CaretLeft, CaretRight } from 'phosphor-react';
|
||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useCallback, useMemo } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { Text } from '../../../Text/Text';
|
|
||||||
import { SwitcherDirection } from './types';
|
import { ExtendedInputRenderProps } from '@components/components/DatePicker/types';
|
||||||
import { ExtendedInputRenderProps } from '../../types';
|
import { SwitcherDirection } from '@components/components/DatePicker/variants/dateSwitcher/types';
|
||||||
|
import { Text } from '@components/components/Text/Text';
|
||||||
|
|
||||||
const StyledContainer = styled.div<{ $opened?: boolean; $disabled?: boolean }>`
|
const StyledContainer = styled.div<{ $opened?: boolean; $disabled?: boolean }>`
|
||||||
border: 1px solid ${(props) => (props.$opened || props.$disabled ? colors.gray[1800] : colors.gray[100])};
|
border: 1px solid ${(props) => (props.$opened || props.$disabled ? colors.gray[1800] : colors.gray[100])};
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { VariantProps } from '../../types';
|
|
||||||
import { CommonVariantProps } from '../common/props';
|
import { VariantProps } from '@components/components/DatePicker/types';
|
||||||
import { DateSwitcherInput } from './components';
|
import { CommonVariantProps } from '@components/components/DatePicker/variants/common/props';
|
||||||
|
import { DateSwitcherInput } from '@components/components/DatePicker/variants/dateSwitcher/components';
|
||||||
|
|
||||||
export const DateSwitcherVariantProps: VariantProps = {
|
export const DateSwitcherVariantProps: VariantProps = {
|
||||||
...CommonVariantProps,
|
...CommonVariantProps,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { CommonVariantProps } from './common/props';
|
import { CommonVariantProps } from '@components/components/DatePicker/variants/common/props';
|
||||||
import { DateSwitcherVariantProps } from './dateSwitcher/props';
|
import { DateSwitcherVariantProps } from '@components/components/DatePicker/variants/dateSwitcher/props';
|
||||||
|
|
||||||
export { CommonVariantProps, DateSwitcherVariantProps };
|
export { CommonVariantProps, DateSwitcherVariantProps };
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Button } from '../Button';
|
|
||||||
import { Drawer } from './Drawer';
|
import { Button } from '@components/components/Button';
|
||||||
import { DrawerProps } from './types';
|
import { Drawer } from '@components/components/Drawer/Drawer';
|
||||||
import { drawerDefault } from './defaults';
|
import { drawerDefault } from '@components/components/Drawer/defaults';
|
||||||
|
import { DrawerProps } from '@components/components/Drawer/types';
|
||||||
|
|
||||||
// Auto Docs
|
// Auto Docs
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Button } from '../Button';
|
|
||||||
import { Text } from '../Text';
|
import { Button } from '@components/components/Button';
|
||||||
import { StyledDrawer, TitleContainer, TitleLeftContainer } from './components';
|
import { StyledDrawer, TitleContainer, TitleLeftContainer } from '@components/components/Drawer/components';
|
||||||
import { maskTransparentStyle } from './constants';
|
import { maskTransparentStyle } from '@components/components/Drawer/constants';
|
||||||
import { DrawerProps } from './types';
|
import { drawerDefault } from '@components/components/Drawer/defaults';
|
||||||
import { drawerDefault } from './defaults';
|
import { DrawerProps } from '@components/components/Drawer/types';
|
||||||
|
import { Text } from '@components/components/Text';
|
||||||
|
|
||||||
export const Drawer = ({
|
export const Drawer = ({
|
||||||
title,
|
title,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { DrawerProps } from './types';
|
import { DrawerProps } from '@components/components/Drawer/types';
|
||||||
|
|
||||||
export const drawerDefault: Omit<DrawerProps, 'title'> = {
|
export const drawerDefault: Omit<DrawerProps, 'title'> = {
|
||||||
width: 600,
|
width: 600,
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
import { BADGE } from '@geometricpanda/storybook-addon-badges';
|
||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Dropdown from './Dropdown';
|
|
||||||
|
import Dropdown from '@components/components/Dropdown/Dropdown';
|
||||||
|
|
||||||
// Auto Docs
|
// Auto Docs
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { Dropdown as AntdDropdown } from 'antd';
|
import { Dropdown as AntdDropdown } from 'antd';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { useOverlayClassStackContext } from '../Utils/OverlayClassContext/OverlayClassContext';
|
|
||||||
import { DropdownProps } from './types';
|
import { DropdownProps } from '@components/components/Dropdown/types';
|
||||||
|
import { useOverlayClassStackContext } from '@components/components/Utils/OverlayClassContext/OverlayClassContext';
|
||||||
|
|
||||||
export default function Dropdown({ children, overlayClassName, ...props }: React.PropsWithChildren<DropdownProps>) {
|
export default function Dropdown({ children, overlayClassName, ...props }: React.PropsWithChildren<DropdownProps>) {
|
||||||
// Get all overlay classes from parents
|
// Get all overlay classes from parents
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
import type { Meta, StoryObj } from '@storybook/react';
|
|
||||||
import { BoldExtension, ItalicExtension } from 'remirror/extensions';
|
|
||||||
import { Remirror, ThemeProvider, useRemirror } from '@remirror/react';
|
|
||||||
import React from 'react';
|
|
||||||
import UserContextProvider from '@src/app/context/UserContextProvider';
|
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
import { Editor } from './Editor';
|
import { Remirror, ThemeProvider, useRemirror } from '@remirror/react';
|
||||||
import { EditorTheme } from './EditorTheme';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import React from 'react';
|
||||||
|
import { BoldExtension, ItalicExtension } from 'remirror/extensions';
|
||||||
|
|
||||||
|
import { Editor } from '@components/components/Editor/Editor';
|
||||||
|
import { EditorTheme } from '@components/components/Editor/EditorTheme';
|
||||||
|
|
||||||
|
import UserContextProvider from '@src/app/context/UserContextProvider';
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
title: 'Components / Editor',
|
title: 'Components / Editor',
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import React, { forwardRef, useEffect, useImperativeHandle } from 'react';
|
import { EditorComponent, Remirror, TableComponents, ThemeProvider, useRemirror } from '@remirror/react';
|
||||||
import DOMPurify from 'dompurify';
|
import DOMPurify from 'dompurify';
|
||||||
|
import React, { forwardRef, useEffect, useImperativeHandle } from 'react';
|
||||||
|
import { useMount } from 'react-use';
|
||||||
import {
|
import {
|
||||||
BlockquoteExtension,
|
BlockquoteExtension,
|
||||||
BoldExtension,
|
BoldExtension,
|
||||||
@ -21,18 +23,17 @@ import {
|
|||||||
TableExtension,
|
TableExtension,
|
||||||
UnderlineExtension,
|
UnderlineExtension,
|
||||||
} from 'remirror/extensions';
|
} from 'remirror/extensions';
|
||||||
import { EditorComponent, Remirror, useRemirror, ThemeProvider, TableComponents } from '@remirror/react';
|
|
||||||
import { useMount } from 'react-use';
|
import { EditorContainer, EditorTheme } from '@components/components/Editor/EditorTheme';
|
||||||
import { EditorContainer, EditorTheme } from './EditorTheme';
|
import { OnChangeMarkdown } from '@components/components/Editor/OnChangeMarkdown';
|
||||||
import { htmlToMarkdown } from './extensions/htmlToMarkdown';
|
import { htmlToMarkdown } from '@components/components/Editor/extensions/htmlToMarkdown';
|
||||||
import { markdownToHtml } from './extensions/markdownToHtml';
|
import { markdownToHtml } from '@components/components/Editor/extensions/markdownToHtml';
|
||||||
import { CodeBlockToolbar } from './toolbar/CodeBlockToolbar';
|
import { DataHubMentionsExtension } from '@components/components/Editor/extensions/mentions/DataHubMentionsExtension';
|
||||||
import { FloatingToolbar } from './toolbar/FloatingToolbar';
|
import { MentionsComponent } from '@components/components/Editor/extensions/mentions/MentionsComponent';
|
||||||
import { Toolbar } from './toolbar/Toolbar';
|
import { CodeBlockToolbar } from '@components/components/Editor/toolbar/CodeBlockToolbar';
|
||||||
import { OnChangeMarkdown } from './OnChangeMarkdown';
|
import { FloatingToolbar } from '@components/components/Editor/toolbar/FloatingToolbar';
|
||||||
import { TableCellMenu } from './toolbar/TableCellMenu';
|
import { TableCellMenu } from '@components/components/Editor/toolbar/TableCellMenu';
|
||||||
import { DataHubMentionsExtension } from './extensions/mentions/DataHubMentionsExtension';
|
import { Toolbar } from '@components/components/Editor/toolbar/Toolbar';
|
||||||
import { MentionsComponent } from './extensions/mentions/MentionsComponent';
|
|
||||||
|
|
||||||
type EditorProps = {
|
type EditorProps = {
|
||||||
readOnly?: boolean;
|
readOnly?: boolean;
|
||||||
|
|||||||
@ -1,7 +1,3 @@
|
|||||||
import { defaultRemirrorTheme } from '@remirror/theme';
|
|
||||||
import type { RemirrorThemeType } from '@remirror/theme';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
extensionBlockquoteStyledCss,
|
extensionBlockquoteStyledCss,
|
||||||
extensionCalloutStyledCss,
|
extensionCalloutStyledCss,
|
||||||
@ -15,6 +11,10 @@ import {
|
|||||||
extensionPositionerStyledCss,
|
extensionPositionerStyledCss,
|
||||||
extensionTablesStyledCss,
|
extensionTablesStyledCss,
|
||||||
} from '@remirror/styles/styled-components';
|
} from '@remirror/styles/styled-components';
|
||||||
|
import { defaultRemirrorTheme } from '@remirror/theme';
|
||||||
|
import type { RemirrorThemeType } from '@remirror/theme';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { ANTD_GRAY } from '@src/app/entityV2/shared/constants';
|
import { ANTD_GRAY } from '@src/app/entityV2/shared/constants';
|
||||||
|
|
||||||
export const EditorTheme: RemirrorThemeType = {
|
export const EditorTheme: RemirrorThemeType = {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useCallback } from 'react';
|
|
||||||
import { useExtensionEvent, useHelpers } from '@remirror/react';
|
|
||||||
import { DocChangedExtension } from '@remirror/core';
|
import { DocChangedExtension } from '@remirror/core';
|
||||||
|
import { useExtensionEvent, useHelpers } from '@remirror/react';
|
||||||
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
export interface OnChangeMarkdownProps {
|
export interface OnChangeMarkdownProps {
|
||||||
onChange: (md: string) => void;
|
onChange: (md: string) => void;
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
import { ErrorConstant, defaultImport, invariant, isElementDomNode } from '@remirror/core';
|
||||||
import _TurndownService from 'turndown';
|
import _TurndownService from 'turndown';
|
||||||
import { gfm } from 'turndown-plugin-gfm';
|
import { gfm } from 'turndown-plugin-gfm';
|
||||||
import { defaultImport, ErrorConstant, invariant, isElementDomNode } from '@remirror/core';
|
|
||||||
import { DATAHUB_MENTION_ATTRS } from './mentions/DataHubMentionsExtension';
|
import { DATAHUB_MENTION_ATTRS } from '@components/components/Editor/extensions/mentions/DataHubMentionsExtension';
|
||||||
|
|
||||||
const TurndownService = defaultImport(_TurndownService);
|
const TurndownService = defaultImport(_TurndownService);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
import { DATAHUB_MENTION_ATTRS } from './mentions/DataHubMentionsExtension';
|
|
||||||
|
import { DATAHUB_MENTION_ATTRS } from '@components/components/Editor/extensions/mentions/DataHubMentionsExtension';
|
||||||
|
|
||||||
marked.use({
|
marked.use({
|
||||||
renderer: {
|
renderer: {
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/* eslint-disable class-methods-use-this */
|
/* eslint-disable class-methods-use-this */
|
||||||
import React, { ComponentType } from 'react';
|
|
||||||
import type { Plugin } from 'prosemirror-state';
|
|
||||||
import {
|
import {
|
||||||
ApplySchemaAttributes,
|
ApplySchemaAttributes,
|
||||||
CommandFunction,
|
CommandFunction,
|
||||||
extension,
|
|
||||||
ExtensionTag,
|
ExtensionTag,
|
||||||
FromToProps,
|
FromToProps,
|
||||||
Handler,
|
Handler,
|
||||||
isElementDomNode,
|
|
||||||
NodeExtension,
|
NodeExtension,
|
||||||
NodeExtensionSpec,
|
NodeExtensionSpec,
|
||||||
NodeSpecOverride,
|
NodeSpecOverride,
|
||||||
omitExtraAttributes,
|
|
||||||
ProsemirrorAttributes,
|
ProsemirrorAttributes,
|
||||||
|
extension,
|
||||||
|
isElementDomNode,
|
||||||
|
omitExtraAttributes,
|
||||||
} from '@remirror/core';
|
} from '@remirror/core';
|
||||||
import { NodeViewComponentProps } from '@remirror/react';
|
import { NodeViewComponentProps } from '@remirror/react';
|
||||||
import autocomplete, {
|
import autocomplete, {
|
||||||
@ -21,7 +19,10 @@ import autocomplete, {
|
|||||||
AutocompleteAction,
|
AutocompleteAction,
|
||||||
pluginKey as acPluginKey,
|
pluginKey as acPluginKey,
|
||||||
} from 'prosemirror-autocomplete';
|
} from 'prosemirror-autocomplete';
|
||||||
import { MentionsNodeView } from './MentionsNodeView';
|
import type { Plugin } from 'prosemirror-state';
|
||||||
|
import React, { ComponentType } from 'react';
|
||||||
|
|
||||||
|
import { MentionsNodeView } from '@components/components/Editor/extensions/mentions/MentionsNodeView';
|
||||||
|
|
||||||
export const DATAHUB_MENTION_ATTRS = {
|
export const DATAHUB_MENTION_ATTRS = {
|
||||||
urn: 'data-datahub-mention-urn',
|
urn: 'data-datahub-mention-urn',
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import { LoadingOutlined } from '@ant-design/icons';
|
||||||
import { useDebounce } from 'react-use';
|
|
||||||
import { FloatingWrapper } from '@remirror/react';
|
import { FloatingWrapper } from '@remirror/react';
|
||||||
import { Empty, Spin } from 'antd';
|
import { Empty, Spin } from 'antd';
|
||||||
import styled from 'styled-components';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { LoadingOutlined } from '@ant-design/icons';
|
import { useDebounce } from 'react-use';
|
||||||
import { Positioner, selectionPositioner } from 'remirror/extensions';
|
import { Positioner, selectionPositioner } from 'remirror/extensions';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import { MentionsDropdown } from '@components/components/Editor/extensions/mentions/MentionsDropdown';
|
||||||
|
import { useDataHubMentions } from '@components/components/Editor/extensions/mentions/useDataHubMentions';
|
||||||
|
|
||||||
import { useUserContext } from '@src/app/context/useUserContext';
|
import { useUserContext } from '@src/app/context/useUserContext';
|
||||||
import { useGetAutoCompleteMultipleResultsLazyQuery } from '@src/graphql/search.generated';
|
import { useGetAutoCompleteMultipleResultsLazyQuery } from '@src/graphql/search.generated';
|
||||||
import { MentionsDropdown } from './MentionsDropdown';
|
|
||||||
import { useDataHubMentions } from './useDataHubMentions';
|
|
||||||
|
|
||||||
const Container = styled.div`
|
const Container = styled.div`
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
@ -1,13 +1,15 @@
|
|||||||
import React, { useCallback, useMemo, useState } from 'react';
|
|
||||||
import { Typography } from 'antd';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
import { useDebounce } from 'react-use';
|
|
||||||
import { useCommands } from '@remirror/react';
|
import { useCommands } from '@remirror/react';
|
||||||
import { useEntityRegistry } from '@src/app/useEntityRegistry';
|
import { Typography } from 'antd';
|
||||||
|
import React, { useCallback, useMemo, useState } from 'react';
|
||||||
|
import { useDebounce } from 'react-use';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import { useDataHubMentions } from '@components/components/Editor/extensions/mentions/useDataHubMentions';
|
||||||
|
|
||||||
import { ANTD_GRAY } from '@src/app/entityV2/shared/constants';
|
import { ANTD_GRAY } from '@src/app/entityV2/shared/constants';
|
||||||
import { AutoCompleteResultForEntity, Entity, EntityType } from '@src/types.generated';
|
|
||||||
import AutoCompleteItem from '@src/app/searchV2/autoComplete/AutoCompleteItem';
|
import AutoCompleteItem from '@src/app/searchV2/autoComplete/AutoCompleteItem';
|
||||||
import { useDataHubMentions } from './useDataHubMentions';
|
import { useEntityRegistry } from '@src/app/useEntityRegistry';
|
||||||
|
import { AutoCompleteResultForEntity, Entity, EntityType } from '@src/types.generated';
|
||||||
|
|
||||||
const HeaderItem = styled(Typography.Text)`
|
const HeaderItem = styled(Typography.Text)`
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
import React from 'react';
|
|
||||||
import { Typography } from 'antd';
|
|
||||||
import { Tooltip } from '@components';
|
import { Tooltip } from '@components';
|
||||||
|
import { NodeViewComponentProps } from '@remirror/react';
|
||||||
|
import { Typography } from 'antd';
|
||||||
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { NodeViewComponentProps } from '@remirror/react';
|
import { IconStyleType } from '@src/app/entityV2/Entity';
|
||||||
import { ANTD_GRAY } from '@src/app/entityV2/shared/constants';
|
import { ANTD_GRAY } from '@src/app/entityV2/shared/constants';
|
||||||
|
import { HoverEntityTooltip } from '@src/app/recommendations/renderer/component/HoverEntityTooltip';
|
||||||
import { useEntityRegistry } from '@src/app/useEntityRegistry';
|
import { useEntityRegistry } from '@src/app/useEntityRegistry';
|
||||||
import { useGetEntityMentionNodeQuery } from '@src/graphql/search.generated';
|
import { useGetEntityMentionNodeQuery } from '@src/graphql/search.generated';
|
||||||
import { IconStyleType } from '@src/app/entityV2/Entity';
|
|
||||||
import { HoverEntityTooltip } from '@src/app/recommendations/renderer/component/HoverEntityTooltip';
|
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { useCallback, useEffect, useState } from 'react';
|
|
||||||
import { useRemirrorContext } from '@remirror/react';
|
import { useRemirrorContext } from '@remirror/react';
|
||||||
import { ActionKind, AutocompleteAction, FromTo } from 'prosemirror-autocomplete';
|
import { ActionKind, AutocompleteAction, FromTo } from 'prosemirror-autocomplete';
|
||||||
import { DataHubMentionsExtension } from './DataHubMentionsExtension';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
import { DataHubMentionsExtension } from '@components/components/Editor/extensions/mentions/DataHubMentionsExtension';
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
active: boolean;
|
active: boolean;
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
import { Form, Input, Modal, Typography } from 'antd';
|
|
||||||
import { useCommands } from '@remirror/react';
|
|
||||||
import { Image } from '@phosphor-icons/react';
|
import { Image } from '@phosphor-icons/react';
|
||||||
|
import { useCommands } from '@remirror/react';
|
||||||
|
import { Form, Input, Modal, Typography } from 'antd';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
import { CommandButton } from '@components/components/Editor/toolbar/CommandButton';
|
||||||
|
|
||||||
import { colors } from '@src/alchemy-components/theme';
|
import { colors } from '@src/alchemy-components/theme';
|
||||||
import { CommandButton } from './CommandButton';
|
|
||||||
|
|
||||||
export const AddImageButton = () => {
|
export const AddImageButton = () => {
|
||||||
const [isModalVisible, setModalVisible] = useState(false);
|
const [isModalVisible, setModalVisible] = useState(false);
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
import { useActive } from '@remirror/react';
|
|
||||||
import { LinkSimpleHorizontal } from '@phosphor-icons/react';
|
import { LinkSimpleHorizontal } from '@phosphor-icons/react';
|
||||||
import { colors } from '@src/alchemy-components/theme';
|
import { useActive } from '@remirror/react';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
import { CommandButton } from './CommandButton';
|
import { CommandButton } from '@components/components/Editor/toolbar/CommandButton';
|
||||||
import { LinkModal } from './LinkModal';
|
import { LinkModal } from '@components/components/Editor/toolbar/LinkModal';
|
||||||
|
|
||||||
|
import { colors } from '@src/alchemy-components/theme';
|
||||||
|
|
||||||
export const AddLinkButton = () => {
|
export const AddLinkButton = () => {
|
||||||
const [isModalVisible, setModalVisible] = useState(false);
|
const [isModalVisible, setModalVisible] = useState(false);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user