-
Notifications
You must be signed in to change notification settings - Fork 310
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
[DRAFT] Search components integration #2582
base: main
Are you sure you want to change the base?
Conversation
…aph-toolkit into feature/search # Conflicts: # package.json # yarn.lock
Thank you for creating a Pull Request @FranckyC. This is a checklist for the PR reviewer(s) to complete before approving and merging this PR:
|
*/ | ||
public static decode(encodedStr: string) { | ||
const domParser = new DOMParser(); | ||
const htmlContent: Document = domParser.parseFromString(`<!doctype html><body>${encodedStr}</body>`, 'text/html'); |
Check warning
Code scanning / CodeQL
Unsafe HTML constructed from library input Medium
library input
cross-site scripting
return /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/.test( | ||
url | ||
); |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
regular expression
library input
…the fluent combobox
…aph-toolkit into feature/search # Conflicts: # tsconfig.base.json # yarn.lock
@gavinbarron @sebastienlevert did you have a chance to review this one and see how we can integrate? Thanks! |
@FranckyC with v3.0 and vacations, this was postponed. We have planed time next week to review the PR and understand what it means for the search components! We'll keep you posted and comment as part of this PR. Thanks! |
Hi @FranckyC, sorry it's taken so long to get back to you on this. There is a lot here! Awesome work! Improved localization supportWe love this, it's a great feature that will allow us to provide support for multilingual sites. Ideally we'd like to bring this into the library as a separate feature/PR which can be built on top of for other aspects of this change. Based on what we can see it's a little unclear how the language that the user is viewing the component in is set. It would be good to provide some more clarity around that. Dynamic importsWe'll need to explore this more thoroughly as we also need to ensure that the dynamic imports work as expected when used from the Although I do wonder if we can achieve the same outcomes as dayJS simply using the browser built in APIs as they do provide great i18n support for language that are installed in the browser. We have an existing example of using the Intl date APIs here: https://github.com/microsoftgraph/microsoft-graph-toolkit/blob/main/packages/mgt-components/src/components/mgt-agenda/mgt-agenda.ts#L667 Is rendering a date using the French output something we'd expect to be doing when the French language is not installed in the browser? I see that the Adaptive cards work is also attempting to use dynamic imports. Dynamic imports are well understood by the TypeScript compiler, we'll just need to adjust the bundler being used to build the bundled output for Tests😍 Thank you so much for providing us with an example of using the web test runner from TailwindThis one is tricky, it's such a shift from how we style all our other web components and is very challenging to adopt due to our investment in Next steps.Component integrationYou raise a valid point about the additional classes and code weight that this brings to the packages, that said we're not overly concerned, as when folks are building using a modern bundling tool the unsused components from In terms of the If we do see real value in spinning off a separate Let's target these changes sitting inside the Localization improvmentsIf this can be split out into a separate change with additional examples to illustrate usage patterns that would be amazing and likely the first of these changes to be brought into the main branch. Again, THANK YOU! This is really fantastic work. p.s. It occurs to us that making you a contributor in the repo and moving your branch there might allow us to collaborate more on this code with the team and we'll be able to make PR's against the feature or WIP branch and also allowing our automation to perform test deployments. Is this a way of working that you would be comfortable with? |
Thanks @sebastienlevert Here are my comments regarding each point: Improved localization support
The language is determined by the localization files locale. I didn't add the language provider component but basically it does the following:
Then every component always loads the default locale file
Whenever the strings.defaults.ts looks like this:
And other localization files (ex strings.fr-fr.ts):
Dynamic imports
I used The thing is this is not only making the TypeScript compiler happy by using By introducing dynamic imports in MGT means to host multiple files instead of one big bundle currently so deployment process would need to be updated as well. Tests
These tests are not really meant for unit testing but more for end-to-end tests. In the case of web components like this, this is way more useful :D Tailwind
I think both approaches can be complementary. Using Tailwind has no impact on the "consumption" side as styles are not exposed in templates anyway. It is only at build time and we only expose CSS variables to consumers. There is probably some work to do to align variables from fluentui theme and Tailwind but that should be feasible. Having Tailwind or not regarding protected methods like
You mean the protected methods like Next steps.Component integration
Yes, my main concern was about the size of this big JavaScript bundle but if you think this is not the way developers consume MGT, that's fine :D Having dynamic imports could help there for sure.
Yes sure it will be easier I guess. |
We think that a developer that wants to bring their own ways of styling would be better inheriting from the "base" Search components (which would be a native MGT component without Tailwind) and add the styling pieces in the
We have a PR up for making proper bundling and better treeshaking. I think this will absolutely help and should reduce a lot the size of projects when leveraging just some components. #2642 As soon as @gavinbarron is back from holidays we'll add your access to our team and we will be able to continue the discussion! Thanks! |
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
PR Type
Feature
Description of the changes
Hi @gavinbarron, @sebastienlevert , as discussed, here is a first functional version of search components integration:
There is still lot of work to do but, at a glance, here are the following changes I've made to make it work:
Tailwind
Added Tailwind CSS integration with postcss and JIT mode. This allow components to use Tailwind styles on demand through dynamically generated
tailwind-styles.css
file. Just useyarn start
as usual and see the content of the file to updated automatically when you add new classes on your components.This relies on a new
tailwindcss
task on @mgt project generating atailwind-styles-css.ts
file and imported into components on-demand:Dynamic imports
For search filters and performances purpose, I need to load correct locale according to the current language using daysJs library. However, because the current solution is not configured to have multiple bundles, I need to add the
inlineDynamicImports
flag on the Rollup config to keep my code as is (only on es6 config for now).As discussed, this is something that needs to be considered in the future to optimize distribution and performances.
Tests
Added test example for search verticals component with
@open-wc/testing
package, web test runner with esplugin/playwright.Added also
useDefineForClassFields
on a customtsconfig.test.json
to make it work with lit (I'm not using Babel).To run tests and watch mode just use
yarn wtr:watch
and the VSCode debug configuration "Tests debug (Edge)":Localization
In our company scenario, localization works for both components internal labels but also settings via attributes (ex: vertical name in multiple languages). For setting values, we define the
ILocalizedString
interface relying on a mandatory "language" property in localization strings:Normally, it is linked to a language provider component globally available on the page and setting this property using the LocalizationHelper but I didn't include it in this demo but you get the idea. Maybe something to think about in the future.
Next steps
Before going forward, we need to decide how to:
PR checklist
yarn build
) and changes have been tested in at least two supported browsers (Edge + non-Chromium based browser)yarn setLicense
)Other information