From 60600084947c8b5b8459419e49d0d71b594f9a8d Mon Sep 17 00:00:00 2001 From: sasse Date: Thu, 16 Jan 2025 09:48:55 +0100 Subject: [PATCH] feat(style): add ts4nfdi and custom styles This is a proposal for the style issue and custom style feature. related to #184 #144 --- src/app/types.ts | 4 +-- .../AutocompleteWidget.stories.tsx | 2 +- .../AutocompleteWidget/AutocompleteWidget.tsx | 8 +++-- .../AutocompleteWidgetHTML.stories.ts | 2 +- .../AutocompleteWidgetStories.ts | 4 +-- .../BreadcrumbPresentation.tsx | 2 +- .../BreadcrumbWidget.stories.tsx | 5 +++- .../BreadcrumbWidget/BreadcrumbWidget.tsx | 19 +++++------- .../BreadcrumbWidgetStories.ts | 29 ++++++++++++++++++- .../TitleWidget/TitleWidget.stories.tsx | 3 +- .../TitleWidget/TitleWidget.tsx | 2 +- .../TitleWidget/TitleWidgetStories.ts | 14 +++++++-- ...Styles.css => customAutocompleteStyle.css} | 3 +- src/style/customBreadcrumbStyle.css | 26 +++++++++++++++++ src/style/semlookp-styles.css | 14 --------- src/style/titleStyles.css | 3 -- src/style/ts4nfdiAutocompleteStyle.css | 21 ++++++++++++++ src/style/ts4nfdiBreadcrumbStyle.css | 25 ++++++++++++++++ src/style/ts4nfdiTitleStyles.css | 11 +++++++ 19 files changed, 150 insertions(+), 47 deletions(-) rename src/style/{autocompleteStyles.css => customAutocompleteStyle.css} (93%) create mode 100644 src/style/customBreadcrumbStyle.css delete mode 100644 src/style/titleStyles.css create mode 100644 src/style/ts4nfdiAutocompleteStyle.css create mode 100644 src/style/ts4nfdiBreadcrumbStyle.css create mode 100644 src/style/ts4nfdiTitleStyles.css diff --git a/src/app/types.ts b/src/app/types.ts index 39f7b6ae..ee264365 100644 --- a/src/app/types.ts +++ b/src/app/types.ts @@ -253,9 +253,9 @@ export type ColorSecondObj = { } -export type BreadcrumbWidgetProps = ApiObj & OptionalEntityTypeObj & OptionalOntologyIdObj & ForcedIriObj & ParameterObj & UseLegacyObj & ColorFirstObj & ColorSecondObj & OnNavigateToOntology; +export type BreadcrumbWidgetProps = ApiObj & OptionalEntityTypeObj & OptionalOntologyIdObj & ForcedIriObj & ParameterObj & UseLegacyObj & ColorFirstObj & ColorSecondObj & OnNavigateToOntology & CssClassNameObj; -export type BreadcrumbPresentationProps = OptionalOntologyIdObj & ColorFirstObj & ColorSecondObj & { +export type BreadcrumbPresentationProps = OptionalOntologyIdObj & ColorFirstObj & ColorSecondObj & CssClassNameObj & { ontologyName: string, shortForm: string, } & OnNavigateToOntology; diff --git a/src/components/widgets/AutocompleteWidget/AutocompleteWidget.stories.tsx b/src/components/widgets/AutocompleteWidget/AutocompleteWidget.stories.tsx index 1a92a5a0..f4981519 100644 --- a/src/components/widgets/AutocompleteWidget/AutocompleteWidget.stories.tsx +++ b/src/components/widgets/AutocompleteWidget/AutocompleteWidget.stories.tsx @@ -38,7 +38,7 @@ export { WithDescriptionAndShortForm, TibNFDI4CHEM, TibDataPlant, - WithStyles + WithCustomStyles } from "./AutocompleteWidgetStories" diff --git a/src/components/widgets/AutocompleteWidget/AutocompleteWidget.tsx b/src/components/widgets/AutocompleteWidget/AutocompleteWidget.tsx index a22cea7c..7761bc54 100644 --- a/src/components/widgets/AutocompleteWidget/AutocompleteWidget.tsx +++ b/src/components/widgets/AutocompleteWidget/AutocompleteWidget.tsx @@ -56,6 +56,8 @@ function AutocompleteWidget(props: AutocompleteWidgetProps) { */ const [selectedOptions, setSelectedOptions] = useState>>([]); + const finalClassName = className || "ts4nfdi-autocomplete-style"; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const renderOption = (option, searchValue) => { @@ -84,7 +86,7 @@ function AutocompleteWidget(props: AutocompleteWidgetProps) { const renderOntology = () => { return ( - + @@ -99,7 +101,7 @@ function AutocompleteWidget(props: AutocompleteWidgetProps) { const renderEntityWithDescription = () => { return ( - + @@ -336,7 +338,7 @@ function AutocompleteWidget(props: AutocompleteWidgetProps) { setSelectedOptions(singleSelection ? [newOption] : [...selectedOptions, newOption]); } return ( -
+
- + -    - {} - - } + {isLoading && } {isSuccess && data && isEntity(data) && } {isError && @@ -55,6 +49,7 @@ function BreadcrumbWidget(props: BreadcrumbWidgetProps) { colorFirst={colorFirst || ((props.ontologyId || (data && data.getOntologyId())) ? "primary" : "danger")} colorSecond={colorSecond || ((data && data.getShortForm()) ? "success" : "danger")} onNavigateToOntology={onNavigateToOntology} + className={finalClassName} /> } diff --git a/src/components/widgets/MetadataWidget/BreadcrumbWidget/BreadcrumbWidgetStories.ts b/src/components/widgets/MetadataWidget/BreadcrumbWidget/BreadcrumbWidgetStories.ts index a5131268..7e3008c5 100644 --- a/src/components/widgets/MetadataWidget/BreadcrumbWidget/BreadcrumbWidgetStories.ts +++ b/src/components/widgets/MetadataWidget/BreadcrumbWidget/BreadcrumbWidgetStories.ts @@ -6,6 +6,8 @@ import { ontologyIdArgType, parameterArgType, useLegacyArgType } from "../../../../stories/storyArgs"; +import "../../../../style/ts4nfdiBreadcrumbStyle.css"; +import "../../../../style/customBreadcrumbStyle.css"; export const BreadcrumbWidgetStoryArgTypes = { ...apiArgType, @@ -31,7 +33,7 @@ export const BreadcrumbWidgetStoryArgs = { onNavigateToOntology: "Console message" }; -export const BreadcrumbWidget1 = { +export const BreadcrumbWidgetDefault = { args: { iri: "http://purl.obolibrary.org/obo/NCIT_C2985", api: globals.ZBMED_API_ENDPOINT, @@ -68,3 +70,28 @@ export const ErrorBreadcrumbWidget = { parameter: "collection=nfdi4health", } }; + +export const CustomColors = { + args: { + iri: "http://purl.obolibrary.org/obo/NCIT_C2985", + api: globals.ZBMED_API_ENDPOINT, + ontologyId: "ncit", + entityType: "term", + parameter: "collection=nfdi4health", + colorFirst: "red", + colorSecond: "grey", + } +}; + +export const CustomStyle = { + args: { + iri: "http://purl.obolibrary.org/obo/NCIT_C2985", + api: globals.ZBMED_API_ENDPOINT, + ontologyId: "ncit", + entityType: "term", + parameter: "collection=nfdi4health", + colorFirst: "#eced8e", + colorSecond: "#8eaeed", + className: "custom-breadcrumb-style" + } +}; diff --git a/src/components/widgets/MetadataWidget/TitleWidget/TitleWidget.stories.tsx b/src/components/widgets/MetadataWidget/TitleWidget/TitleWidget.stories.tsx index 2e202c49..c66c57c7 100644 --- a/src/components/widgets/MetadataWidget/TitleWidget/TitleWidget.stories.tsx +++ b/src/components/widgets/MetadataWidget/TitleWidget/TitleWidget.stories.tsx @@ -24,5 +24,6 @@ export { IncorrectIriWithoutDefaultValue, SelectingDefiningOntology, DefiningOntologyUnavailable, - TitleWidgetWithStyles + TitleWidgetWithStyles, + TitleWidgetWithoutStyles, } from "./TitleWidgetStories"; diff --git a/src/components/widgets/MetadataWidget/TitleWidget/TitleWidget.tsx b/src/components/widgets/MetadataWidget/TitleWidget/TitleWidget.tsx index af8b3bc3..91873fb4 100644 --- a/src/components/widgets/MetadataWidget/TitleWidget/TitleWidget.tsx +++ b/src/components/widgets/MetadataWidget/TitleWidget/TitleWidget.tsx @@ -24,7 +24,7 @@ function TitleWidget(props: TitleWidgetProps) { className } = props; const olsApi = new OlsApi(api); - const finalClassName = className || "default-class"; + const finalClassName = className || "ts4nfdi-title-style"; const { data, diff --git a/src/components/widgets/MetadataWidget/TitleWidget/TitleWidgetStories.ts b/src/components/widgets/MetadataWidget/TitleWidget/TitleWidgetStories.ts index 6bea66c4..50165e4d 100644 --- a/src/components/widgets/MetadataWidget/TitleWidget/TitleWidgetStories.ts +++ b/src/components/widgets/MetadataWidget/TitleWidget/TitleWidgetStories.ts @@ -8,7 +8,7 @@ import { thingTypeArgType, titleTextArgType, useLegacyArgType } from "../../../../stories/storyArgs"; -import "../../../../style/titleStyles.css"; +import "../../../../style/ts4nfdiTitleStyles.css"; export const TitleWidgetStoryArgTypes = { ...apiArgType, @@ -96,7 +96,17 @@ export const TitleWidgetWithStyles = { api: globals.ZBMED_API_ENDPOINT, ontologyId: "ncit", thingType: "term", - className: 'title-styles', + className: 'custom-title-style', + } +}; + +export const TitleWidgetWithoutStyles = { + args: { + iri: "http://purl.obolibrary.org/obo/NCIT_C2985", + api: globals.ZBMED_API_ENDPOINT, + ontologyId: "ncit", + thingType: "term", + className: 'none', } }; diff --git a/src/style/autocompleteStyles.css b/src/style/customAutocompleteStyle.css similarity index 93% rename from src/style/autocompleteStyles.css rename to src/style/customAutocompleteStyle.css index 9a4c09fe..b6f8f3a5 100644 --- a/src/style/autocompleteStyles.css +++ b/src/style/customAutocompleteStyle.css @@ -1,5 +1,4 @@ .custom-autocomplete-style * { - font-size: 18px !important; font-family: 'Inter',BlinkMacSystemFont,Helvetica,Arial,sans-serif; } @@ -20,4 +19,4 @@ .euiComboBoxOptionsList__empty { font-family: 'Inter',BlinkMacSystemFont,Helvetica,Arial,sans-serif; -} +} \ No newline at end of file diff --git a/src/style/customBreadcrumbStyle.css b/src/style/customBreadcrumbStyle.css new file mode 100644 index 00000000..5c7f1347 --- /dev/null +++ b/src/style/customBreadcrumbStyle.css @@ -0,0 +1,26 @@ +.custom-breadcrumb-style * { +} + +.custom-breadcrumb-style button { + background: none; + border: none; +} + +.euiBadge * { + font-family: 'Inter',BlinkMacSystemFont,Helvetica,Arial,sans-serif; +} + +.custom-breadcrumb-style .clickable-breadcrumb { + +} + +.custom-breadcrumb-style .breadcrumb { + padding: 6px 6px 0; + border-radius: 0; + border: 10px solid rgba(0,0,0,0); + +} + +.custom-breadcrumb-style .clickable-breadcrumb:hover { + border: 2px solid black; +} \ No newline at end of file diff --git a/src/style/semlookp-styles.css b/src/style/semlookp-styles.css index ccd0900e..71881d3d 100644 --- a/src/style/semlookp-styles.css +++ b/src/style/semlookp-styles.css @@ -5,20 +5,6 @@ button { user-select: text; } -.clickable-breadcrumb { - -} - -.breadcrumb { - padding: 3px 3px 0; - border-radius: 6px; - border: 2px solid rgba(0,0,0,0); -} - -.clickable-breadcrumb:hover { - border: 2px solid black; -} - .surroundCircle { border-radius: 50%; height: 17px; diff --git a/src/style/titleStyles.css b/src/style/titleStyles.css deleted file mode 100644 index 8901a67f..00000000 --- a/src/style/titleStyles.css +++ /dev/null @@ -1,3 +0,0 @@ -.title-styles *{ - font-weight: bold; -} \ No newline at end of file diff --git a/src/style/ts4nfdiAutocompleteStyle.css b/src/style/ts4nfdiAutocompleteStyle.css new file mode 100644 index 00000000..74278047 --- /dev/null +++ b/src/style/ts4nfdiAutocompleteStyle.css @@ -0,0 +1,21 @@ +.ts4nfdi-autocomplete-style * { + font-family: 'Inter',BlinkMacSystemFont,Helvetica,Arial,sans-serif; +} + +.ts4nfdi-autocomplete-style input, +.ts4nfdi-autocomplete-style .euiComboBox__inputWrap{ +} + +.ts4nfdi-autocomplete-style button { + background: none; + border: none; +} + +.euiComboBoxOptionsList * { + border: none; + background-color: inherit; +} + +.euiComboBoxOptionsList__empty { + font-family: 'Inter',BlinkMacSystemFont,Helvetica,Arial,sans-serif; +} diff --git a/src/style/ts4nfdiBreadcrumbStyle.css b/src/style/ts4nfdiBreadcrumbStyle.css new file mode 100644 index 00000000..7bcc9851 --- /dev/null +++ b/src/style/ts4nfdiBreadcrumbStyle.css @@ -0,0 +1,25 @@ +.ts4nfdi-breadcrumb-style * { +} + +.ts4nfdi-breadcrumb-style button { + background: none; + border: none; +} + +.euiBadge * { + font-family: 'Inter',BlinkMacSystemFont,Helvetica,Arial,sans-serif; +} + +.ts4nfdi-breadcrumb-style .clickable-breadcrumb { + +} + +.ts4nfdi-breadcrumb-style .breadcrumb { + padding: 3px 3px 0; + border-radius: 6px; + border: 2px solid rgba(0,0,0,0); +} + +.ts4nfdi-breadcrumb-style .clickable-breadcrumb:hover { + border: 2px solid black; +} \ No newline at end of file diff --git a/src/style/ts4nfdiTitleStyles.css b/src/style/ts4nfdiTitleStyles.css new file mode 100644 index 00000000..8c7827e5 --- /dev/null +++ b/src/style/ts4nfdiTitleStyles.css @@ -0,0 +1,11 @@ +.ts4nfdi-title-style * { + font-family: 'Inter',BlinkMacSystemFont,Helvetica,Arial,sans-serif; + color: #343741 !important; +} + +.custom-title-style * { + font-family: 'Inter',BlinkMacSystemFont,Helvetica,Arial,sans-serif; + color: #0645AD !important; + background-color: #76b6ec; +} +