Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support accordion block, description block, teaser block. Make tooltip component customizable. #14

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
db84c5d
Fix AddonRegistry
ksuess Dec 20, 2024
f803274
Create TooltipPopup.jsx
ksuess Dec 20, 2024
65e203b
Delete TODO.md
ksuess Dec 20, 2024
6878591
Fix accordion block. Prepare for description block and teaser block. …
ksuess Dec 20, 2024
641c980
Format
ksuess Dec 20, 2024
833a429
Revert "Fix AddonRegistry"
ksuess Dec 20, 2024
8cf5018
Fix unused import, etc
ksuess Dec 20, 2024
9b575c7
Update README.md
ksuess Dec 20, 2024
7d1de27
Update README.md
ksuess Dec 20, 2024
adb7012
Update to Volto 18.7.0. Add
ksuess Jan 30, 2025
b424559
Add package "@eeacms/volto-accordion-block" for demo purpose
ksuess Jan 30, 2025
c649b20
Add example views for description block and teaser block
ksuess Jan 30, 2025
eeaafb7
Rename test to .jsx
ksuess Jan 31, 2025
855db09
Fix tests
ksuess Jan 31, 2025
99f0da4
Update Makefile: Add `make check`
ksuess Jan 31, 2025
c42949f
Add comment for demo setup
ksuess Jan 31, 2025
76de70c
Remove example acceptance test
ksuess Jan 31, 2025
892f69e
Delete storybook.yml
ksuess Jan 31, 2025
0ca7b8d
Remove import of example components for description with tooltips and…
ksuess Jan 31, 2025
6ad8bf0
Update comments in policy configuration
ksuess Feb 2, 2025
9ce45e3
Update README
ksuess Feb 2, 2025
f053fd7
Add example title block view with tooltips applied
ksuess Feb 2, 2025
da3aedb
example teaser view: apply tooltips also to title, not only text/desc…
ksuess Feb 2, 2025
7008238
policy: apply tooltips to all components
ksuess Feb 2, 2025
d4d033a
policy: reorder add-ons. policy last.
ksuess Feb 2, 2025
3e4e0ae
refactor component Tooltips
ksuess Feb 2, 2025
f95624e
policy: customize accordion block view
ksuess Feb 2, 2025
db35c7e
Update example content
ksuess Feb 2, 2025
4daa668
Fix tests
ksuess Feb 2, 2025
dfdcbfb
Update README Add instructions for demo
ksuess Feb 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
const fs = require('fs');
const projectRootPath = __dirname;
const AddonConfigurationRegistry = require('@plone/registry/src/addon-registry');
const { AddonRegistry } = require('@plone/registry/addon-registry');

let coreLocation;
if (fs.existsSync(`${projectRootPath}/core`))
coreLocation = `${projectRootPath}/core`;
else if (fs.existsSync(`${projectRootPath}/../../core`))
coreLocation = `${projectRootPath}/../../core`;

const registry = new AddonConfigurationRegistry(
`${coreLocation}/packages/volto`,
);
const { registry } = AddonRegistry.init(`${coreLocation}/packages/volto`);

// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
const addonAliases = Object.keys(registry.packages).map((o) => [
Expand Down
102 changes: 0 additions & 102 deletions .github/workflows/acceptance.yml

This file was deleted.

57 changes: 0 additions & 57 deletions .github/workflows/storybook.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
run: make install

- name: Unit tests
run: make test-ci
run: make ci-test
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ backend-test: ## Test backend codebase
# $(MAKE) -C "./backend/" clean
# $(MAKE) -C "./frontend/" clean

# .PHONY: check
# check: ## Lint and Format codebase
# @echo "Lint and Format codebase"
# $(PRE_COMMIT) run -a


###########################################
# Frontend
Expand Down Expand Up @@ -149,12 +144,17 @@ release-dry-run: ## Dry-run the release of the add-on on npmjs.org
test: ## Run unit tests
pnpm test

.PHONY: test-ci
.PHONY: ci-test
ci-test: ## Run unit tests in CI
# Unit Tests need the i18n to be built
VOLTOCONFIG=$(pwd)/volto.config.js pnpm --filter @plone/volto i18n
CI=1 RAZZLE_JEST_CONFIG=$(CURRENT_DIR)/jest-addon.config.js pnpm --filter @plone/volto test -- --passWithNoTests

.PHONY: check
check: ## Lint and Format codebase (run pre-commit)
@echo "Lint and Format codebase"
$(PRE_COMMIT) run -a

.PHONY: backend-docker-start
backend-docker-start: ## Starts a Docker-based backend for development
@echo "$(GREEN)==> Start Docker-based Plone Backend$(RESET)"
Expand Down
134 changes: 127 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,12 @@ Regardless of this setting, when you have a fully uppercase term, for example `R

By default we show tooltips for all occurrences of a term.

Since version 2.0.0 you can configure to only show tooltips for the first occurence on a page.
You can configure to only show tooltips for the first occurence on a page.

```js
config.settings.glossary.matchOnlyFirstOccurence = true;
```


User can opt-out by setting glossarytooltips to false.
Add a boolean member field *glossarytooltips* for it.

## Further configurations

Hide alphabet navigation of glossary view:

```js
Expand All @@ -69,3 +63,129 @@ Show glossary term in tooltips header:
```js
config.settings.glossary.mentionTermInTooltip = true;
```

Show tooltips also in text blocks of an [accordion block](https://github.com/eea/volto-accordion-block):

```js
config.settings.glossary.includeAccordionBlock = true;
```


### Show tooltips also in a teaser block

Per default only texts of slate blocks are equipped with tooltips.
`TextWithGlossaryTooltips` can be used to enhance other texts with tooltip markup.

Create a custom `TeaserView` component in your project:

```js
import TeaserBody from '@plone/volto/components/manage/Blocks/Teaser/Body';
import { withBlockExtensions } from '@plone/volto/helpers/Extensions';
import { TextWithGlossaryTooltips } from '@rohberg/volto-slate-glossary/utils';

const TeaserView = (props) => {
return (
<TeaserBody
{...{
...props,
data: {
...props.data,
description: TextWithGlossaryTooltips({
text: props.data.description,
}),
},
}}
/>
);
};

export default withBlockExtensions(TeaserView);
mauritsvanrees marked this conversation as resolved.
Show resolved Hide resolved
```

Register your `TeaserView` component:

```js
import TeaserViewWithTooltips from './components/TeaserViewWithTooltips'; // import by speaking name

const applyConfig = (config) => {
// your project configuration…

// teaser block with tooltips
config.blocks.blocksConfig.teaser.view = TeaserViewWithTooltips;
// teaser block in grid block also with tooltips
config.blocks.blocksConfig.gridBlock.blocksConfig.teaser.view =
TeaserViewWithTooltips;

return config;
};

export default applyConfig;
```

You can find the code also via `packages/policy/src/index.js`.


### Show tooltips also in a description block

Per default only texts of slate blocks are equipped with tooltips.
`TextWithGlossaryTooltips` can be used to enhance other texts with tooltip markup.

Create a custom `DescriptionBlockView` in your project:

```js
import { TextWithGlossaryTooltips } from '@rohberg/volto-slate-glossary/utils';

const DescriptionBlockView = ({ properties, metadata, id }) => {
let description = (metadata || properties)['description'] || '';
description = TextWithGlossaryTooltips({ text: description });

return <p className="documentDescription">{description}</p>;
};

export default DescriptionBlockView;
````

Register your `DescriptionBlockView` component:

```js
config.blocks.blocksConfig.description.view = DescriptionBlockViewWithTooltips; // import by speaking name
```

You can find the code also via `packages/policy/src/index.js`.


### Register Custom tooltip component

The tooltip component can be replaced by a custom one.

```js
config.registerComponent({
name: 'TooltipPopup',
component: CustomTooltipPopup,
});
````

## Demo

To see the add-on in action, set up backend and frontend of this package.

backend:

```shell
make backend-install
make backend-create-site
make backend-start
```

frontend:

```shell
make install
make start
```


## Opt-out for users

A user can opt-out by setting glossarytooltips to false.
Add a boolean member field `glossarytooltips` to provide this.
3 changes: 0 additions & 3 deletions TODO.md

This file was deleted.

Loading