Граф коммитов

10 Коммитов

Автор SHA1 Сообщение Дата
udgathad 39850fbd1e add reject all button to main banner 2022-02-13 14:46:57 -08:00
BillChou0114 e5e7b25940
Add nonce attribute to style tags and setNonceAttribute(...) method (#27)
* Fix esc key in IE

Instead of `event.key == 'Escape'` in Chrome or Firefox, IE used
`event.key == 'Esc'`.

* `showBanner(...)` only create banner.

In previous version, `showBanner(...)` will create banner and hidden
dialog. In the new version, `showBanner(...) will only create banner.

When user clicks `More info` button, it will call `showPreference(...)`
to create a dialog.

When `onPreferencesDialogShowing()` is called, it will check the dialog
is in the DOM or not. Since the only method to remove the dialog is
`hidePreferencesDialog()`, and it will set
`this.previousFocusElementBeforePopup = null;`, we use
`this.previousFocusElementBeforePopup` to determine the dialog is
in the DOM or not. If there is a dialog, we will not add event listener.

* Add new test cases and update old ones

* Add nonce to style tags and `setNonceAttribute(...)` method

1. Add nonce to all style tags
2. Add `setNonceAttribute(...)` method to set nonce attribute
3. Use `textContent` to replace `innerHTML` to change theme

* Set style nonce in constructor

1. Add stylesNonce in IOptions
2. Add webpack-dev-server configuration for Content Security Policy
3. Set style nonce in constructor

* Update `.d.ts` file and document

1. Add `stylesNonce` in interface `IOptions` and related methods
2. Update `showPreferences(...)`

* Update webpack.production.config.js and bump npm version

* Add explanation in stylesNonce

* Simplify webpack.config.js

Use webpack-merge to simplify webpack configuration file.
webpack.common.js is the common part in developmment and production. Use
webpack.dev.js and webpack.prod.js to insert the development and
production specific configuration.

* Update `nonce` attribute in style tag

Since loaders are stateless, we need to reload it if we want to change
it. Instead, we get the styles contents and remove the blocked style
element with style element id. With the styles contents and passed
`nonce`, we can create the new style element that will not be blocked.

If we removed `style-loader` and loaded style element by ourselves, the
actual styles contents will be `styles[0][1]`.

Reference:
https://webpack.js.org/contribute/writing-a-loader/
https://webpack.js.org/guides/hot-module-replacement/

* Use `style-loader` to `inject` styles and `nonce` to `<style>`

* Only add `nonce` to `<style>` if it is not empty

1. Only add `nonce` to `<style>` when options.stylesNonce is not empty
2. Remove private methods in `.d.ts` file

* Update Jest config and test cases

The new file applied in configuration is based on `identity-obj-proxy`.
styles.locals.bannerBody -> bannerBody

Check:
https://github.com/keyz/identity-obj-proxy/blob/master/src/index.js

* Update test cases

Co-authored-by: Bill Chou (Zen3 Infosolutions America Inc) <v-tincho@microsoft.com>
2020-10-05 14:15:09 -07:00
BillChou0114 0c0f86edd3
Fix the side of radio buttons in rtl (#20)
Co-authored-by: Bill Chou <v-tincho@microsoft.com>
2020-09-11 15:08:46 -07:00
BillChou0114 a012abaff3
Show focus frame for radio buttons
Co-authored-by: Bill Chou <v-tincho@microsoft.com>
2020-09-09 14:48:53 -07:00
BillChou0114 9f839fb6cd
Keep focus on tab within the popup dialog 2020-08-31 14:39:38 -07:00
Bill Chou (Zen3 Infosolutions America Inc) 3711981b2c Update documents 2020-08-26 12:57:41 -07:00
Bill Chou (Zen3 Infosolutions America Inc) eb15c5a483 Update `.d.ts` file to include new methods and types
1. Update `consent-banner.d.ts` to include `Theme` related methods
1.1 Update constructor
1.2 Add `applyTheme()` and `createTheme()`
1.3 Add related data types

2. Increase npm version
2020-08-25 15:50:13 -07:00
Bill Chou (Zen3 Infosolutions America Inc) 30fa3f00fe Add more details in interfaces
Add more details in interfaces for consumers to use in static typing.
2020-07-16 14:42:49 -07:00
Bill Chou (Zen3 Infosolutions America Inc) 35e458703d Add types 2020-07-02 16:04:22 -07:00
Max Shmelev c9adb26f9c init 2020-04-16 20:26:18 -07:00