Skip to content

Commit

Permalink
- Storybook doc fixes and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck Cornu committed Jan 16, 2024
1 parent a6994cf commit 3dc8e8a
Show file tree
Hide file tree
Showing 12 changed files with 4,799 additions and 4,744 deletions.
9,399 changes: 4,712 additions & 4,687 deletions packages/components/custom-elements.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export class SearchResultsComponent extends BaseComponent {
</div>
<div class="flex mt-1 mb-1 ml-0 mr-0pt-[3px] space-x-1">
<div>
${resource?.lastModifiedBy?.user?.displayName ? `${strings.modifiedBy} ${resource?.lastModifiedBy?.user?.displayName}` : null }
${resource?.lastModifiedBy?.user?.displayName ? `${this.strings.modifiedBy} ${resource?.lastModifiedBy?.user?.displayName}` : null }
</div>
<div>
${ resource.lastModifiedDateTime ?
Expand Down Expand Up @@ -496,7 +496,7 @@ export class SearchResultsComponent extends BaseComponent {
</div>
<div class="flex mt-1 mb-1 ml-0 mr-0 dark:text-textColorDark pt-[3px] space-x-1">
<div>
${resource?.lastModifiedBy?.user?.displayName ? `${strings.modifiedBy} ${resource?.lastModifiedBy?.user?.displayName}` : null }
${resource?.lastModifiedBy?.user?.displayName ? `${this.strings.modifiedBy} ${resource?.lastModifiedBy?.user?.displayName}` : null }
</div>
<div>
${ resource.lastModifiedDateTime ?
Expand Down Expand Up @@ -941,7 +941,7 @@ export class SearchResultsComponent extends BaseComponent {
];
}

protected override get strings() {
protected override get strings(): { [x: string]: string; } {
return strings;
}

Expand Down
Binary file not shown.
Binary file added packages/components/src/stories/assets/pnp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,28 @@ Aggregations are useful to group multiple filter values to an unique one with a

To use aggegations, pass the following properties to the `aggregations` filter configuration property:

<Source
language='json'
dark
format={false}
code={dedent`
{
...Other filter properties
aggregations: [
{
"aggregationName":{
"fr-fr":"Document Word",
"ro-ro":"document Word",
"default":"Word document"
},
"matchingValues":[
"docx",
"doc",
"docm"
],
"aggregationValue":"or(\"docx\",\"doc\",\"docm\")",
"aggregationValueIconUrl":"http://localhost:8000/assets/icons/word.svg"
}
]
}
`}
/>
```json
{
...Other filter properties
aggregations: [
{
"aggregationName":{
"fr-fr":"Document Word",
"ro-ro":"document Word",
"default":"Word document"
},
"matchingValues":[
"docx",
"doc",
"docm"
],
"aggregationValue":"or(\"docx\",\"doc\",\"docm\")",
"aggregationValueIconUrl":"http://localhost:8000/assets/icons/word.svg"
}
]
...
}
```

| Property | Description | Example |
| -------- | ----------- | -------- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const AdvancedQueryTemplate = (args) => {
fields=${args.fields.join(",")}
page-size=${args["page-size"]}
sort-properties=${JSON.stringify(args["sort-properties"])}
theme=${args["theme"]}
>
</pnp-search-results>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To use a custom template, simply use the `<template>` directive inside the conte
>
<template data-type="items">
<div data-for='item in items'>
<!-- Template content here using [[item.<prop>]] binding syntax -->
<!-- Template content here using {{item.<prop>}} binding syntax -->
</div>
</template>
</pnp-search-results>
Expand All @@ -36,7 +36,7 @@ Where valid `data-type` attribute values are:
- **items** to customize results display.
- **shimmers** to customize display when results are loading

> By default the binding syntax fo componetns is `[[<expr>]]` and you can use regular Javascript here.
> By default the binding syntax for components is `{{<expr>}}` and you can use regular Javascript here.
### Template: result items

Expand All @@ -52,8 +52,8 @@ This template is used **after results are loaded**:
<div data-for='item in items'>
<div class="pb-8">
<div class="flex space-x-2 mb-2">
<div class="font-bold">[[item.resource.fields.title]]</div>
<div class="h-6">By [[item.resource.fields.createdBy]]</div>
<div class="font-bold">{{item.resource.fields.title}}</div>
<div class="h-6">By {{item.resource.fields.createdBy}}</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const CustomItemsTemplate = (args) => {
entity-types=${args["entity-types"]}
fields=${args.fields.join(",")}
page-size=${args["page-size"]}
theme=${args["theme"]}
>
<template data-type="items">
Expand Down Expand Up @@ -76,6 +77,7 @@ const CustomHeaderTemplate = (args) => {
see-all-link=${args["see-all-link"]}
comp-title=${args["comp-title"]}
?show-count=${args["show-count"]}
theme=${args["theme"]}
>
</pnp-search-results>
`;
Expand All @@ -94,6 +96,7 @@ const PagingTemplate = (args) => {
page-size=${args["page-size"]}
pages-number=${args["pages-number"]}
?show-paging=${args["show-paging"]}
theme=${args["theme"]}
>
</pnp-search-results>
`;
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/stories/introduction/auth.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { Meta } from '@storybook/blocks';
# Authentication

To get it work, some components need the current user to be logged in against Azure AD and the Microsoft 365 tenant where you try get data from.
The PnP Modern Search core components bundle include the Microsoft Graph Toolkit library `3.0.0` so it means you can use any components from it, like [authentication providers](https://learn.microsoft.com/en-us/graph/toolkit/providers/providers).
The PnP Modern Search core components bundle include the Microsoft Graph Toolkit library `3.1.3` so it means you can use any components from it, like [authentication providers](https://learn.microsoft.com/en-us/graph/toolkit/providers/providers).

The only thing to keep in mind is we use a dedicated **pnp** prefix for MGT components. Example:

```
```html
<mgt-pnp-file>
```

Provider component needs to be added to your page so other components that require authentication can work. Here is an example with the mSAL2 provider:
Provider component needs to be added to your page so other components that require authentication can work. Here is an example with the MSAL2 provider:


Example:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import { Meta, Source } from '@storybook/blocks';
import { PACKAGE_VERSION } from "../../../src/utils/version";
import m365logo from "../assets/m365_logo.png";
import pnpLogo from "../assets/pnp.png";
import ubisoftLogo from "../assets/ubisoft_stacked_logo_black.png";

<Meta title="Introduction / Getting started" />

# PnP Modern Search - Core components

<img width="162px" src={m365logo}/>
<div style={{display: 'flex', justifyContent: 'center', height: '150px'}}>
<img alt="PnP Logo"src={pnpLogo}/>
<img alt="Ubisoft Logo" src={ubisoftLogo}/>
</div>

## What's included?

The following components are included in the bundle:

| Component | HTML tag | Purpose |
|-----------------------------------------------------------------------------------|-------------------------------|---------------------------------------------------------------------------------|
| [Search results](?path=/docs/components-search-search-results--usage-query) | `<pnp-search-results>` | Display results from Microsoft Search index according to configured parameters. |
| [Search filters](?path=/docs/components-search-search-filters--usage) | `<pnp-filters>` | Display filters from a connected search results components |
| [Search box](?path=/docs/components-search-search-box--usage) | `<pnp-search-input>` | Allow users to enter free text search keywords. |
| [Search verticals](?path=/docs/components-search-search-verticals--usage) | `<pnp-search-verticals>` | Displays tabs to search by verticals |
| Component | HTML tag | Purpose |
| --------- | -------- | ------- |
| [Search results](https://azpnpmodernsearchcoresto.z9.web.core.windows.net/latest/index.html?path=/docs/components-search-search-results--usage-query) | `<pnp-search-results>` | Display results from Microsoft Search index according to configured parameters. |
| [Search filters](https://azpnpmodernsearchcoresto.z9.web.core.windows.net/latest/index.html?path=/docs/components-search-search-filters--usage) | `<pnp-search-filters>` | Display filters from a connected search results components |
| [Search box](https://azpnpmodernsearchcoresto.z9.web.core.windows.net/latest/index.html?path=/docs/components-search-search-box--usage) | `<pnp-search-input>` | Allow users to enter free text search keywords.
| [Search verticals](https://azpnpmodernsearchcoresto.z9.web.core.windows.net/latest/index.html?path=/docs/components-search-search-verticals--usage) | `<pnp-search-verticals>` | Displays tabs to search by verticals |
| [Video player](https://azpnpmodernsearchcoresto.z9.web.core.windows.net/latest/index.html?path=/docs/components-misc-video-player--usage) | `<pnp-video-player>` | Play video from SharePoint (outside of SharePoint domain) |

## Usage

Expand All @@ -32,18 +37,19 @@ Include the following script in your HTML page:
/>

> Components are registered automatically on the page when the package is imported.
> Use [versions numbers](https://www.npmjs.com/package/@pnp/modern-search-core?activeTab=versions) from `npm`.
### Via npm package

The npm package `@pnp/modern-search-core` is available in npm to be used in you application
The npm package [`@pnp/modern-search-core`](https://www.npmjs.com/package/@pnp/modern-search-core) is available in npm to be used in you application

### Installation

`npm i --save @pnp/modern-search-core`

### Side effects

The `@pnp/modern-search-core` package is side effect free, expect for the entrypoints located under _define/_ folder;
The [`@pnp/modern-search-core`](https://www.npmjs.com/package/@pnp/modern-search-core) package is side effect free, except for the entrypoints located under _define/_ folder;

### Usage

Expand All @@ -59,22 +65,46 @@ import "@pnp/modern-search-core/dist/es6/exports/define/pnp-search-results";
```

#### Scoped
When used in a microfrontend, you'll probably need to use scoped elements to avoid any registration conflicts:
When used in a microfrontend, you'll probably need to use scoped elements to avoid any registration conflicts

`import { PnPSearchResultsComponent} from "@pnp/modern-search-core";`
**Manually defined element**

```typescript
import { SearchResultsComponent} from "@pnp/modern-search-core";

// Use the PnPSearchResultsComponent with the scoped element mixin (https://open-wc.org/docs/development/scoped-elements/)
// or
// define your component with SearchResultsComponent
// Define your component manually with SearchResultsComponent
if (!customElements.get("myapp-search-results")) {
customElements.define("myapp-search-results", PnPSearchResultsComponent)
customElements.define("myapp-search-results", SearchResultsComponent)
}
...
<myapp-search-results
id="edfdea93-23c9-4ba6-94d9-a848a1384104"
/>
<myapp-search-results />
```

Will register the PnPSearchResultsComponent component under the name myapp-search-results in the custom element registry.
**[Scoped element mixin](https://open-wc.org/docs/development/scoped-elements/) in your own web component**

```typescript

//
import { SearchResultsComponent} from "@pnp/modern-search-core";
import { ScopedElementsMixin } from "@open-wc/scoped-elements";

export class MyComponent extends ScopedElementsMixin(LitElement) {

...

static get scopedElements() {
return {
"myapp-search-results": SearchResultsComponent
};
}
...

public render() {
...

return html`<myapp-search-results />`;
}
...
}

```
2 changes: 1 addition & 1 deletion packages/spfx/src/layouts/results/tiles/results-tiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
<div class="font-bold line-clamp-2 h-full">
<a href='{{ slot("Path",item) }}' target="_blank">{{ slot("Title",item) }}</a>
</div>
</div>
<div data-if='slot("Subtitle",item)' class="">{{ slot("Subtitle",item) }}</div>
<div data-if='slot("Summary",item)' class="p-2 h-full">
<p data-html class="line-clamp-4">{{ slot("Summary",item) }}</p>
Expand Down

0 comments on commit 3dc8e8a

Please sign in to comment.