@newskit-render/standalone-components 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -200,7 +200,7 @@ You need to have Algolia credentials as enviromnent variables:
200
200
 
201
201
  2.1. Context
202
202
 
203
- This is the default context which all the pages use out of the box
203
+ This is the default context for all the pages use out of the box
204
204
 
205
205
  ```
206
206
  export const baseContext: BaseContextOptions = {
@@ -319,7 +319,7 @@ export const baseContext: BaseContextOptions = {
319
319
  ```
320
320
  2.2 Properties of BaseContextOptions
321
321
 
322
- 1. baseUrl - relative url when the help hub landinpage lives
322
+ 1. baseUrl - relative url when the help hub landing page lives
323
323
 
324
324
  2. seo: - Used in the Header component
325
325
 
@@ -419,29 +419,85 @@ export const baseContext: BaseContextOptions = {
419
419
 
420
420
 
421
421
 
422
- As said above, help hub consists of three pages and we will take a look on how to add each one of them individually. Standalone-components package exports page components and a provider function for each page.
422
+ As said above, help hub consists of three pages and we will take a look on how to add each one of them individually.
423
+
424
+ Each page extend the above BaseContextOptions with their own properties:
425
+
426
+ 2.3 HelpHubLandingPageContextOptions
427
+
428
+ 1. articlesTabelInfo
429
+ - title: string
430
+ - titleOverrides
431
+ - typographyPreset: MQ
432
+ - stylePreset: MQ
433
+ - spaceStack: string
434
+ - as: h1 | h2 | h3 | h4 | h5 | h6
435
+ 2. mostReadArticles: [
436
+ {
437
+ - title: string
438
+ - objectID: string
439
+ }
440
+ ]
441
+
442
+ 2.4 ResultsPageContextOptions
443
+
444
+ 1. hits: [
445
+ {
446
+ - title: string
447
+ - objectID: string
448
+ - content: string
449
+ }
450
+ ]
451
+ 2. introductionProps:
452
+ - title: string
453
+ - titleOverrides
454
+ - typographyPreset: MQ
455
+ - stylePreset: MQ
456
+ - spaceStack: string
457
+ - as: h1 | h2 | h3 | h4 | h5 | h6
458
+ - description: string
459
+ - showDivider: boolean
460
+ 3. stylePreset: MQ<string>
461
+ 4. showDividerByBreakpoint: boolean
462
+
463
+ 2.5 ArticlePageContextOptions
464
+
465
+ 1. introductionProps:
466
+ - titleOverrides
467
+ - typographyPreset: MQ
468
+ - stylePreset: MQ
469
+ - spaceStack: string
470
+ - as: h1 | h2 | h3 | h4 | h5 | h6
471
+ 2. title: string
472
+ 3. content: string
473
+
474
+ Standalone-components package exports page components, page context, page context types (PageContextOptions) and a provider function for each page.
475
+
476
+ 2.6 Help-Hub Landing page.
423
477
 
424
- 2.3. Help-Hub Landing page.
425
478
  As stated above, landing page will display the most read articles. For now these articles are hardcoded and need to be passed to the Landing page (see example below). These articles must be already imported in Algolia in order for them to work.
426
479
 
480
+ This example shows how to set up the page and override the page context with your own values:
481
+
427
482
  ```typescript
428
483
  import React, { useContext } from 'react'
429
484
  import newrelic from 'newrelic'
430
485
  import {
486
+ AlgoliaCredentials,
431
487
  HelpHubLandingPage,
488
+ helpHubLandingPageContext,
489
+ HelpHubLandingPageContextOptions,
432
490
  helpHubLandingPageProvider,
433
491
  } from '@newskit-render/standalone-components'
434
492
  import { createThemeDropdownObject } from '../../helpers/createThemeDropdownObject'
435
493
  import { AppContext } from '../../context'
436
494
  import { addCacheHeaders } from '../../helpers/addCacheHeaders'
437
495
 
438
- const landingPageContext: Partial<LandingPageContextOptions> = {
496
+ const landingPageContext: Partial<HelpHubLandingPageContextOptions> = {
497
+ ...helpHubLandingPageContext,
439
498
  header: {
440
499
  title: 'Your custom title',
441
500
  },
442
- articlesTabelInfo: {
443
- title: 'Yout custom table title',
444
- },
445
501
  mostReadArticles: [
446
502
  {
447
503
  title: 'Sign-in with Google',
@@ -469,7 +525,7 @@ const landingPageContext: Partial<LandingPageContextOptions> = {
469
525
  title: 'Can I share my Times & Sunday Times iPad subscription access?',
470
526
  objectID: 'can-i-share-my-times-sunday-times-ipad-subscription-access',
471
527
  },
472
- ]
528
+ ],
473
529
  }
474
530
 
475
531
  const LandingPage: React.FC<{
@@ -481,7 +537,7 @@ const LandingPage: React.FC<{
481
537
  return (
482
538
  <HelpHubLandingPage
483
539
  {...props}
484
- context={{ mostReadArticles }}
540
+ context={landingPageContext}
485
541
  customTheme={theme}
486
542
  themeDropdownObject={themeDropdownObject}
487
543
  />
@@ -500,7 +556,7 @@ export const getServerSideProps = async (context) => {
500
556
  }
501
557
  ```
502
558
 
503
- 2.4. Help-hub Search Results page.
559
+ 2.7 Help-hub Search Results page.
504
560
 
505
561
  example usage:
506
562
 
@@ -512,12 +568,15 @@ import {
512
568
  AlgoliaCredentials,
513
569
  Hit,
514
570
  helpHubResultsProvider,
571
+ helpHubResultsPageContext,
572
+ HelpHubResultsPageContextOptions,
515
573
  } from '@newskit-render/standalone-components'
516
574
  import { createThemeDropdownObject } from '../../helpers/createThemeDropdownObject'
517
575
  import { AppContext } from '../../context'
518
576
  import { addCacheHeaders } from '../../helpers/addCacheHeaders'
519
577
 
520
- const resultsPageContext: Partial<ResultsPageContextOptions> = {
578
+ const resultsPageContext: Partial<HelpHubResultsPageContextOptions> = {
579
+ ...helpHubResultsPageContext,
521
580
  header: {
522
581
  title: 'Search results custom title',
523
582
  description: 'Your search for "##QUERY##" returned ##COUNT## results',
@@ -543,6 +602,7 @@ const ResultsPage: React.FC<{
543
602
  <HelpHubResultsPage
544
603
  {...props}
545
604
  customTheme={theme}
605
+ context={resultsPageContext}
546
606
  themeDropdownObject={themeDropdownObject}
547
607
  />
548
608
  )
@@ -560,7 +620,7 @@ export const getServerSideProps = async (context) => {
560
620
  }
561
621
  ```
562
622
 
563
- 2.5. Help-hub Help Article page. Article page uses Next.js router to get the article parameter in order to fetch the article. The parameter is called title. That means that your path in Next routing system should look like this:
623
+ 2.8 Help-hub Help Article page. Article page uses Next.js router to get the article parameter in order to fetch the article. The parameter is called title. That means that your path in Next routing system should look like this:
564
624
 
565
625
  `help-hub/article/[title]/index.tsx`
566
626
 
@@ -570,13 +630,28 @@ Example use:
570
630
  import React, { useContext } from 'react'
571
631
  import newrelic from 'newrelic'
572
632
  import {
633
+ AlgoliaCredentials,
573
634
  HelpHubArticlePage,
574
635
  helpHubArticleProvider,
636
+ helpHubArticlePageContext,
637
+ HelpHubArticlePageContextOptions,
575
638
  } from '@newskit-render/standalone-components'
576
639
  import { createThemeDropdownObject } from '../../../../helpers/createThemeDropdownObject'
577
640
  import { AppContext } from '../../../../context'
578
641
  import { addCacheHeaders } from '../../../../helpers/addCacheHeaders'
579
642
 
643
+ const articlePageContext: Partial<HelpHubArticlePageContextOptions> = {
644
+ ...helpHubArticlePageContext,
645
+ introductionProps: {
646
+ titleOverrides: {
647
+ typographyPreset: { xs: 'utilityHeading040', sm: 'utilityHeading050' },
648
+ stylePreset: 'inkContrast',
649
+ spaceStack: 'space040',
650
+ as: 'h1',
651
+ },
652
+ },
653
+ }
654
+
580
655
  const ArticlePage: React.FC<{
581
656
  credentials: AlgoliaCredentials
582
657
  title: string
@@ -589,6 +664,7 @@ const ArticlePage: React.FC<{
589
664
  <HelpHubArticlePage
590
665
  {...props}
591
666
  customTheme={theme}
667
+ context={articlePageContext}
592
668
  themeDropdownObject={themeDropdownObject}
593
669
  />
594
670
  )
@@ -2,4 +2,5 @@ export * from './pages';
2
2
  export * from './provider';
3
3
  export * from './types';
4
4
  export { PagesNameMap } from './context';
5
+ export type { LandingPageContextOptions as HelpHubLandingPageContextOptions, ArticlePageContextOptions as HelpHubArticlePageContextOptions, ResultsPageContextOptions as HelpHubResultsPageContextOptions, } from './context';
5
6
  export type { AlgoliaCredentials } from './types';
@@ -1,4 +1,4 @@
1
- import ArticlePage from './ArticlePage';
2
- import LandingPage from './LandingPage';
3
- import ResultsPage from './ResultsPage';
4
- export { ArticlePage as HelpHubArticlePage, LandingPage as HelpHubLandingPage, ResultsPage as HelpHubResultsPage, };
1
+ import ArticlePage, { articlePageContext } from './ArticlePage';
2
+ import LandingPage, { landingPageContext } from './LandingPage';
3
+ import ResultsPage, { resultsPageContext } from './ResultsPage';
4
+ export { ArticlePage as HelpHubArticlePage, articlePageContext as helpHubArticlePageContext, LandingPage as HelpHubLandingPage, landingPageContext as helpHubLandingPageContext, ResultsPage as HelpHubResultsPage, resultsPageContext as helpHubResultsPageContext, };
@@ -1,13 +1,36 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.HelpHubResultsPage = exports.HelpHubLandingPage = exports.HelpHubArticlePage = void 0;
7
- var ArticlePage_1 = __importDefault(require("./ArticlePage"));
26
+ exports.helpHubResultsPageContext = exports.HelpHubResultsPage = exports.helpHubLandingPageContext = exports.HelpHubLandingPage = exports.helpHubArticlePageContext = exports.HelpHubArticlePage = void 0;
27
+ var ArticlePage_1 = __importStar(require("./ArticlePage"));
8
28
  exports.HelpHubArticlePage = ArticlePage_1.default;
9
- var LandingPage_1 = __importDefault(require("./LandingPage"));
29
+ Object.defineProperty(exports, "helpHubArticlePageContext", { enumerable: true, get: function () { return ArticlePage_1.articlePageContext; } });
30
+ var LandingPage_1 = __importStar(require("./LandingPage"));
10
31
  exports.HelpHubLandingPage = LandingPage_1.default;
11
- var ResultsPage_1 = __importDefault(require("./ResultsPage"));
32
+ Object.defineProperty(exports, "helpHubLandingPageContext", { enumerable: true, get: function () { return LandingPage_1.landingPageContext; } });
33
+ var ResultsPage_1 = __importStar(require("./ResultsPage"));
12
34
  exports.HelpHubResultsPage = ResultsPage_1.default;
35
+ Object.defineProperty(exports, "helpHubResultsPageContext", { enumerable: true, get: function () { return ResultsPage_1.resultsPageContext; } });
13
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/help-hub/pages/index.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAuC;AAKtB,6BALV,qBAAW,CAKiB;AAJnC,8DAAuC;AAKtB,6BALV,qBAAW,CAKiB;AAJnC,8DAAuC;AAKtB,6BALV,qBAAW,CAKiB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/help-hub/pages/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA+D;AAK9C,6BALV,qBAAW,CAKiB;AACX,0GANF,gCAAkB,OAMS;AALjD,2DAA+D;AAM9C,6BANV,qBAAW,CAMiB;AACX,0GAPF,gCAAkB,OAOS;AANjD,2DAA+D;AAO9C,6BAPV,qBAAW,CAOiB;AACX,0GARF,gCAAkB,OAQS"}
@@ -2,4 +2,5 @@ export * from './pages';
2
2
  export * from './provider';
3
3
  export * from './types';
4
4
  export { PagesNameMap } from './context';
5
+ export type { LandingPageContextOptions as HelpHubLandingPageContextOptions, ArticlePageContextOptions as HelpHubArticlePageContextOptions, ResultsPageContextOptions as HelpHubResultsPageContextOptions, } from './context';
5
6
  export type { AlgoliaCredentials } from './types';
@@ -1,4 +1,4 @@
1
- import ArticlePage from './ArticlePage';
2
- import LandingPage from './LandingPage';
3
- import ResultsPage from './ResultsPage';
4
- export { ArticlePage as HelpHubArticlePage, LandingPage as HelpHubLandingPage, ResultsPage as HelpHubResultsPage, };
1
+ import ArticlePage, { articlePageContext } from './ArticlePage';
2
+ import LandingPage, { landingPageContext } from './LandingPage';
3
+ import ResultsPage, { resultsPageContext } from './ResultsPage';
4
+ export { ArticlePage as HelpHubArticlePage, articlePageContext as helpHubArticlePageContext, LandingPage as HelpHubLandingPage, landingPageContext as helpHubLandingPageContext, ResultsPage as HelpHubResultsPage, resultsPageContext as helpHubResultsPageContext, };
@@ -1,5 +1,5 @@
1
- import ArticlePage from './ArticlePage';
2
- import LandingPage from './LandingPage';
3
- import ResultsPage from './ResultsPage';
4
- export { ArticlePage as HelpHubArticlePage, LandingPage as HelpHubLandingPage, ResultsPage as HelpHubResultsPage, };
1
+ import ArticlePage, { articlePageContext } from './ArticlePage';
2
+ import LandingPage, { landingPageContext } from './LandingPage';
3
+ import ResultsPage, { resultsPageContext } from './ResultsPage';
4
+ export { ArticlePage as HelpHubArticlePage, articlePageContext as helpHubArticlePageContext, LandingPage as HelpHubLandingPage, landingPageContext as helpHubLandingPageContext, ResultsPage as HelpHubResultsPage, resultsPageContext as helpHubResultsPageContext, };
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/help-hub/pages/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,WAAW,MAAM,eAAe,CAAA;AAEvC,OAAO,EACL,WAAW,IAAI,kBAAkB,EACjC,WAAW,IAAI,kBAAkB,EACjC,WAAW,IAAI,kBAAkB,GAClC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/help-hub/pages/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,EAAE,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,WAAW,EAAE,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,WAAW,EAAE,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAE/D,OAAO,EACL,WAAW,IAAI,kBAAkB,EACjC,kBAAkB,IAAI,yBAAyB,EAC/C,WAAW,IAAI,kBAAkB,EACjC,kBAAkB,IAAI,yBAAyB,EAC/C,WAAW,IAAI,kBAAkB,EACjC,kBAAkB,IAAI,yBAAyB,GAChD,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newskit-render/standalone-components",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Newskit Render Standalone Components",
5
5
  "author": "",
6
6
  "license": "UNLICENSED",