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

#579: Nieuwe release maken Cookie Consent module #39

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

CountNick
Copy link
Contributor

  • Update the readme
    • Since the cookie-consent is now a custom element the readme has been adjusted accordingly to be used in a vanilla js project. The old module had the option to choose between radio buttons and checkboxes. There is no option to choose anymore it will always be a list of checkboxes right now. Is this something that needs to be re-added?
  • Update the default stylesheet
    • Since this is now a custom element, the html is rendered in a shadow DOM therefore it won't be possible to just style the element from the outside with class names. This now has to be done with specific ::part's I've updated the default stylesheet to now use those.
  • Update the save preferences button
    • I noticed the button always showed the default value, it's now been adjusted to be able to show custom text as well.

@CountNick CountNick changed the title Feature/update readme #579: Nieuwe release maken Cookie Consent module Jun 17, 2024
Copy link
Member

@harmenjanssen harmenjanssen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for preparing the release, Nick!
I feel like there are a couple small things to look into before we take this out of beta.

Please let me know if any comments are unclear or if you want to look into something together.

README.md Outdated

window.CookieConsent = cookieConsent;
export const DEFAULTS = {
type: "checkbox",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here "type: checkbox" is still listed.
If we don't support otherwise, I would remove this option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has now been removed

README.md Outdated
el.addEventListener('click', e => {
e.preventDefault();
cookieConsent.hideDialog();
el.addEventListener("click", (e) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous example you use button.addEventListener, I would do so here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been changed to button.addEventListener

README.md Outdated
/**
* Header
*/
wookie-consent::part(cookie-consent__header) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 Wookie-consent!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha oops, this has been adjusted to cookie-consent

});
```

### isAccepted(id: string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to all methods that have been removed from the README?
They all sound very useful. If they are gone, I would like to make some GH issues to remind us to re-implement them.
(talking about isAccepted, getPreferences, on, and updatePreferences)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see in dialog.mjs the methods are still available, so I would like to return the documentation on them as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, I didn't see. Everything has been re-added except for isAccepted this method is not being used anymore as this can be easily checked in the frontend right now after cookies have been updated.

src/dialog.mjs Outdated
Comment on lines 29 to 53
// sets and returns 'this.shadowRoot'
this.attachShadow({ mode: "open" });
// get data
this.data = this.getData();
// get config
this.config = this.getConfig();
// initialize event dispatcher
this.events = this.initEventDispatcher();
// initialize teblist
this.tabList = this.initTabList();
// get cookies
this.cookies = this.data.cookies;
// generate dialog element
this.dialogElement = this.generateDialogElement();
// append dialog to shadowRoot
this.shadowRoot.append(this.dialogElement);
// get preferences
this.preferences = this.getPreferences();
// initialize domtoggler
this.domToggler = this.initDomToggler();
// initialize show and hide
this.show = this.show();
this.hide = this.hide();
// get all preferences
this.preferences.getAll();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the comments add a lot of value here, they're nearly copies of the actual lines of code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you suggest, should they be removed or rephrased? 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they can be safely removed!

src/dialog.mjs Outdated

// Radio when no option is selected.
if (TYPE === 'radio' && !values.find(v => v.accepted)) {
if (this.config.type === "radio" && !values.find((v) => v.accepted)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are also still references to radiobuttons.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now gone

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to leave this test intact.
It's a really simple test, feels doable to reproduce it for the new module version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is now rewritten to work with the custom element

src/dialog.mjs Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to CookieConsent? (cookie-consent.mjs)
It makes sense to me that the "main" element in this module is called "cookie consent" and not "dialog". It feels more intuitive to the developers working on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 🙂

@harmenjanssen
Copy link
Member

Oh, and regarding the checkboxes versus radiobuttons: can you elaborate on why the radiobuttons are no longer supported?

If we don't use them in client projects it's fine to move ahead with this, but let's in any case make an issue here on GitHub to keep track of the status of that feature.

Copy link

@JairoTheDev JairoTheDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harmenjanssen is zo te zien al bezig geweest! Ik heb ook nog paar kleine comments.

README.md Outdated
- When showing, the module will remove any inline set `display` style, along with any `hidden` or `aria-hidden` attributes.

## Options
Once registered, you can add the cookie-consent element to your HTML, you can pass custom data attributes for the:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deze zin loopt niet helemaal lekker! Misschien kan je het beter veranderen in:

Suggested change
Once registered, you can add the cookie-consent element to your HTML, you can pass custom data attributes for the:
Once registered, you can add the cookie-consent element to your HTML and pass custom data attributes for the following:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks! Dit is aangepast

- title
- description
- save button text
- cookie types

```js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dit loopt nog niet helemaal lekker in elkaar over. De data attributes worden benoemd, maar dit wordt pas verder uitgelegd onder het kopje Options. Misschien kan dit allemaal verplaatst worden on het kopje Options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ook dit is nu wat aangepast

@CountNick
Copy link
Contributor Author

Oh, and regarding the checkboxes versus radiobuttons: can you elaborate on why the radiobuttons are no longer supported?

If we don't use them in client projects it's fine to move ahead with this, but let's in any case make an issue here on GitHub to keep track of the status of that feature.

The radio buttons are no longer supported because the necessary cookies should always be selected and therefore any other option added should also be selectable. A list of checkboxes would mean only one option could be selected

@harmenjanssen
Copy link
Member

Oh, and regarding the checkboxes versus radiobuttons: can you elaborate on why the radiobuttons are no longer supported?
If we don't use them in client projects it's fine to move ahead with this, but let's in any case make an issue here on GitHub to keep track of the status of that feature.

The radio buttons are no longer supported because the necessary cookies should always be selected and therefore any other option added should also be selectable. A list of checkboxes would mean only one option could be selected

But are there always required cookies? In the past this could be used with all-optional cookies I think.

Copy link
Member

@harmenjanssen harmenjanssen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, Nick, thanks for the updates!
This is starting to look good.

Can you look into the failing CI processes?

I would prefer to have a little more tests, just to have some affordance that this update does indeed keep existing functionality intact, but since there were so little to begin with, we can get away with moving them to the backlog and work on them in retrospect.
But for instance, a check that the public methods still work would be very nice to have.

@CountNick
Copy link
Contributor Author

Oh, and regarding the checkboxes versus radiobuttons: can you elaborate on why the radiobuttons are no longer supported?
If we don't use them in client projects it's fine to move ahead with this, but let's in any case make an issue here on GitHub to keep track of the status of that feature.

The radio buttons are no longer supported because the necessary cookies should always be selected and therefore any other option added should also be selectable. A list of checkboxes would mean only one option could be selected

But are there always required cookies? In the past this could be used with all-optional cookies I think.

To be fair I don't really know, what I do know is that it's legal to always have functional cookies on. But then again I don't really know whether or not they're always necessary.

@CountNick
Copy link
Contributor Author

@harmenjanssen all CI processes are now succeeding except for the slack notification is this something that needs to be fixed as well?

@CountNick
Copy link
Contributor Author

@harmenjanssen the slack notification is now also succeeding

@CountNick CountNick requested a review from harmenjanssen June 19, 2024 08:51
Copy link
Member

@harmenjanssen harmenjanssen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@CountNick CountNick force-pushed the feature/update-readme branch from 34785e1 to 86dc5a3 Compare June 20, 2024 07:59
Add config functions

Update code

Add data attributes

Update code

Update custom events

Update template

Remove redundant code

Fix show and hide dialog functionality

Remove old code

Revert to .mjs

Update formatting

Update imports

Update import

Remove @types/react

Update dialog

Update dialog

Update tablist

Add parameters to function

Remove redundant file

Fix linter error

Update test

Update checked state

Remove whitespaces

Update yarn lock

Fix linting errors

Remove failing test

Remove aria-description

1.2.1-beta.1

Update cookie-consent to custom element

Add config functions

Update code

Add data attributes

Update code

Update custom events

Update template

Remove redundant code

Fix show and hide dialog functionality

Remove old code

Revert to .mjs

Update formatting

Update imports

Update import

Remove @types/react

Update dialog

Update dialog

Update tablist

Add parameters to function

Remove redundant file

Fix linter error

Update test

Update checked state

Remove whitespaces

Update yarn lock

Fix linting errors

Remove failing test

Remove aria-description

Hide cookie consent in print media styles

Remove idea files

Remove idea files

Remove idea workspace file

Update dialog generateDialogElement method

Update imports with file extension

Update package version grrr utils

Updated defaultbuttonLabel to defaultButtonLabel

Update README

Update README

Update README

Update button label

Update stylesheet

Update readme

Update code

Update readme

Update string quotes

Re-add test

Format code

Update slack notification

Format code

Update version

Format files
@CountNick CountNick force-pushed the feature/update-readme branch from 7e61f25 to 403bd7c Compare June 20, 2024 09:39
@CountNick CountNick merged commit 72d9319 into master Jun 20, 2024
4 checks passed
@CountNick CountNick deleted the feature/update-readme branch June 20, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants