@bitrise/bitkit 9.5.2 → 9.5.4-alpha-chakra.1

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.
Files changed (105) hide show
  1. package/package.json +5 -1
  2. package/src/tsconfig.tsbuildinfo +1 -0
  3. package/src/variables.css +2 -3
  4. package/.browserslistrc +0 -2
  5. package/.editorconfig +0 -4
  6. package/.eslint-tsconfig.json +0 -7
  7. package/.eslintrc.js +0 -28
  8. package/.husky/commit-msg +0 -4
  9. package/.nvmrc +0 -1
  10. package/.storybook/main.js +0 -35
  11. package/.storybook/manager.js +0 -6
  12. package/.storybook/preview.tsx +0 -20
  13. package/.storybook/theme.js +0 -7
  14. package/.stylelintignore +0 -2
  15. package/.stylelintrc +0 -287
  16. package/.svgrrc.js +0 -52
  17. package/.tool-versions +0 -1
  18. package/@types/@bitrise/bitkit.ts +0 -1
  19. package/@types/react-docgen.ts +0 -119
  20. package/CHANGELOG.md +0 -996
  21. package/CONTRIBUTING.md +0 -79
  22. package/FAQ.md +0 -19
  23. package/bitrise.yml +0 -66
  24. package/commitlint.config.js +0 -10
  25. package/jest.setup.js +0 -36
  26. package/netlify.toml +0 -42
  27. package/postcss.config.js +0 -16
  28. package/release.config.js +0 -32
  29. package/renovate.json +0 -6
  30. package/scripts/build-docs-watch.ts +0 -7
  31. package/scripts/build-docs.ts +0 -59
  32. package/site/assets/fonts/TT_Norms_Pro_Bold.woff +0 -0
  33. package/site/assets/fonts/TT_Norms_Pro_Normal.woff +0 -0
  34. package/site/assets/icons/favicon-32x32.png +0 -0
  35. package/site/assets/images/app_icon.jpg +0 -0
  36. package/site/assets/images/status-checks.png +0 -0
  37. package/site/components/CodeBlock/CodeBlock.css +0 -87
  38. package/site/components/CodeBlock/CodeBlock.tsx +0 -35
  39. package/site/components/Documentation/ComponentDocumentationPage.tsx +0 -150
  40. package/site/components/Documentation/Components/SectionAddonBeam.tsx +0 -47
  41. package/site/components/Documentation/Components/SectionAddonBeamSandbox.tsx +0 -32
  42. package/site/components/Documentation/Components/SectionAddonFooter.tsx +0 -22
  43. package/site/components/Documentation/Components/SectionAppear.tsx +0 -59
  44. package/site/components/Documentation/Components/SectionAvatar.tsx +0 -50
  45. package/site/components/Documentation/Components/SectionBadge.tsx +0 -38
  46. package/site/components/Documentation/Components/SectionBase.tsx +0 -17
  47. package/site/components/Documentation/Components/SectionButtons.tsx +0 -361
  48. package/site/components/Documentation/Components/SectionCards.tsx +0 -276
  49. package/site/components/Documentation/Components/SectionCheckbox.tsx +0 -38
  50. package/site/components/Documentation/Components/SectionDatePicker.tsx +0 -82
  51. package/site/components/Documentation/Components/SectionDivider.tsx +0 -31
  52. package/site/components/Documentation/Components/SectionDot.tsx +0 -27
  53. package/site/components/Documentation/Components/SectionDropdowns.tsx +0 -388
  54. package/site/components/Documentation/Components/SectionExpand.tsx +0 -143
  55. package/site/components/Documentation/Components/SectionFlex.tsx +0 -33
  56. package/site/components/Documentation/Components/SectionFormElements.tsx +0 -187
  57. package/site/components/Documentation/Components/SectionGrid.tsx +0 -125
  58. package/site/components/Documentation/Components/SectionHamburger.tsx +0 -34
  59. package/site/components/Documentation/Components/SectionIcons.tsx +0 -30
  60. package/site/components/Documentation/Components/SectionInputs.tsx +0 -89
  61. package/site/components/Documentation/Components/SectionList.tsx +0 -26
  62. package/site/components/Documentation/Components/SectionModals.tsx +0 -224
  63. package/site/components/Documentation/Components/SectionNotification.tsx +0 -38
  64. package/site/components/Documentation/Components/SectionPlacement.tsx +0 -167
  65. package/site/components/Documentation/Components/SectionProgress.tsx +0 -149
  66. package/site/components/Documentation/Components/SectionRadioButton.tsx +0 -38
  67. package/site/components/Documentation/Components/SectionRibbon.tsx +0 -33
  68. package/site/components/Documentation/Components/SectionRibbonSandbox.tsx +0 -17
  69. package/site/components/Documentation/Components/SectionSidebar.tsx +0 -125
  70. package/site/components/Documentation/Components/SectionSkeleton.tsx +0 -99
  71. package/site/components/Documentation/Components/SectionStatus.tsx +0 -53
  72. package/site/components/Documentation/Components/SectionStatusSandbox404.tsx +0 -42
  73. package/site/components/Documentation/Components/SectionStatusSandbox500.tsx +0 -13
  74. package/site/components/Documentation/Components/SectionTable.tsx +0 -83
  75. package/site/components/Documentation/Components/SectionTabs.tsx +0 -25
  76. package/site/components/Documentation/Components/SectionText.tsx +0 -34
  77. package/site/components/Documentation/Components/SectionTextarea.tsx +0 -43
  78. package/site/components/Documentation/Components/SectionToggle.tsx +0 -50
  79. package/site/components/Documentation/Components/SectionTooltips.tsx +0 -50
  80. package/site/components/Documentation/Documentation.tsx +0 -302
  81. package/site/components/Documentation/Materials/SectionColors.css +0 -33
  82. package/site/components/Documentation/Materials/SectionColors.tsx +0 -197
  83. package/site/components/Documentation/Materials/SectionIcons.tsx +0 -106
  84. package/site/components/Documentation/Materials/SectionTypography.tsx +0 -143
  85. package/site/components/Page/Page.tsx +0 -8
  86. package/site/components/Page/PageTitle.tsx +0 -8
  87. package/site/components/PropsTable/PropsTable.tsx +0 -35
  88. package/site/components/PropsTable/PropsTableCellUnion.tsx +0 -29
  89. package/site/components/PropsTable/PropsTableRow.tsx +0 -55
  90. package/site/components/Root/Root.tsx +0 -89
  91. package/site/components/Root/index.tsx +0 -4
  92. package/site/components/Sandbox/Sandbox.tsx +0 -19
  93. package/site/components/Sandbox/SandboxFrame.css +0 -20
  94. package/site/components/Sandbox/SandboxFrame.tsx +0 -77
  95. package/site/components/Section/Section.tsx +0 -8
  96. package/site/components/Section/SectionSubTitle.tsx +0 -8
  97. package/site/components/Section/SectionTitle.tsx +0 -8
  98. package/site/components/SideMenu/SideMenu.css +0 -39
  99. package/site/components/SideMenu/SideMenu.tsx +0 -53
  100. package/site/components/SideMenu/SideMenuItem.tsx +0 -34
  101. package/site/components/Window/Window.tsx +0 -62
  102. package/site/index.css +0 -11
  103. package/site/index.html +0 -16
  104. package/site/index.tsx +0 -16
  105. package/superstatic.json +0 -13
package/CONTRIBUTING.md DELETED
@@ -1,79 +0,0 @@
1
- ## Commit Messages
2
-
3
- This project is following **continuous deployment** using Bitrise CI 🙌.
4
-
5
- Bitkit uses a strict commit message structure that follows the [Conventional Commits](https://www.conventionalcommits.org) spec. This is used to automate publishing the package to NPM and generating the [CHANGELOG](../CHANGELOG.md) with [Semantic Release](https://github.com/semantic-release/semantic-release).
6
-
7
- Any changes to the consumable resources of the library should trigger a release, which can be done with the following commit types.
8
-
9
- | Commit | Release type |
10
- |---|---|
11
- | Commit with breaking change | Major Breaking release |
12
- | Commit with type `feat` | Minor release |
13
- | Commit with type `fix` | Patch release |
14
- | Commit with type `style` | Patch release |
15
- | Commit with type `perf` | Patch release |
16
-
17
- Some examples...
18
-
19
- ```
20
- fix(Button): Removed `pointer-events` rule that prevented it from being clickable.
21
- feat(DatePicker): Added `range` prop to allow start and end dates to be selected.
22
- style(Avatar): Updated colors of the avatar backgrounds.
23
- chore(ESlint): Added rule 'blahblah'.
24
- ```
25
-
26
- Here, the `chore()` type would not trigger a new release.
27
-
28
- ## Design Review
29
-
30
- Some changes that get submitted to Bitkit may include design changes, which should be approved by someone on the design team.
31
-
32
- It is down to the developer to assess whether they think they require a design review, when they think this is needed, they should tag the Github handle of one of the designers on the Pull Request that has the changes.
33
-
34
- The Pull Request should have enough information to indicate to the designer what has been changed, and what they should look at, if not a cheeky slack chat is always a good idea.
35
-
36
- We use Netlify for branch deployments on Pull Requests. One of the Github statuses on the Pull Request will be "deploy/netlify - Deploy preview ready!". Here you can preview the changes made on that Pull Request.
37
-
38
- ![Status Checks](./site/assets/images/status-checks.png)
39
-
40
- ## Component Guidance
41
-
42
- Finding the balance of flexibility, scalability and usefulness is hard with Pattern Libraries. Components should remain useful in multiple contexts while also being ready to extend and scale as the design or usecases evolve.
43
-
44
- **Style Guide Driven Development** - The Style Guide helps to document the contents of the Pattern Library for users and also acts as an isolated development environment. It should be possible to see all variations of a component to validate it's implementation and how it reacts to any changes made at a later date.
45
-
46
- **The Open/Closed Principle** - Components should be _"Open for extension but Closed for modification"_. To help the pattern library scale, maintain and for components to remain reusable in as many contexts as possible, components should be built with API like CSS (using BEM) and should not reference a selector or override styles from another CSS module.
47
-
48
- For example, "The Button inside the DatePicker should be bigger".
49
-
50
- Instead of this...
51
-
52
- ```css
53
- /* Button.css */
54
- .Button { padding: 12px 16px; }
55
-
56
- /* DatePicker.css */
57
- .DatePicker .Button { padding: 16px 24px; }
58
- ```
59
-
60
- ... or this...
61
-
62
- ```jsx
63
- <Button className="DatePickerButton">...</Button>
64
- ```
65
-
66
- ```css
67
- .DatePickerButton {
68
- padding: 16px 24px;
69
- }
70
- ```
71
-
72
- A better way would be
73
-
74
- ```css
75
- /* Button.css */
76
- .Button { }
77
- .Button--size-small { padding: 12px 16px; }
78
- .Button--size-large { padding: 16px 24px; }
79
- ```
package/FAQ.md DELETED
@@ -1,19 +0,0 @@
1
- ## FAQ
2
-
3
-
4
- #### "Why can't I pass in my own CSS classes to components?"
5
-
6
- There are two types of components inside Bitkit, 'styled' components and 'utility' components. The utility components **do** support custom CSS classes. The styled components all provide styling from the design system. The components and their variations should remain available for everyone to use and should be predictable to changes that are made inside this library. For this reason, they do not allow custom CSS classes.
7
-
8
- By allowing custom styling and classes to be added to these components, it would create random overriding variations that are not documented and react in unpredictable ways between releases. This is also why referencing the CSS selectors of Bitkit components is discouraged.
9
-
10
- Even if this wasn't the case, some components might also have a slightly more complicated template structure and would require an API that allows CSS classes to be added to every node in the outputted template.
11
-
12
- Some possible reasons for needing to do this -
13
-
14
- • **Adding some layout styling to position the component** - A better way to achieve this would be to follow _["The Single Responsibility Principle"](https://cssguidelin.es/#the-single-responsibility-principle)_, and use wrapping layout components (like Flex).
15
-
16
- • **Adding some visual styling to adjust the appearance of the component** - A better way to achieve this is either verify this is a needed style and contribute it as a variation extension to the current component API or adjust the design and use a variation that already exists.
17
-
18
- • **It's a one off use case that is needed** - It's best to try and avoid these on offs where possible by adjusting the designs or environment that has caused the situation. If not there are the utility components like `Base`, `Flex`, `Grid` and `Text` that are general use components that all provide a lot of styling that might get you what you need and that also **do** support passing custom CSS classes.
19
-
package/bitrise.yml DELETED
@@ -1,66 +0,0 @@
1
- ---
2
- format_version: '8'
3
- default_step_lib_source: 'https://github.com/bitrise-io/bitrise-steplib.git'
4
- project_type: other
5
- trigger_map:
6
- - push_branch: master
7
- workflow: Master
8
- - push_branch: 'alpha*'
9
- workflow: AlphaBranch
10
- - pull_request_source_branch: '*'
11
- workflow: PullRequests
12
- pull_request_target_branch: master
13
- workflows:
14
- AlphaBranch:
15
- before_run:
16
- - Primary
17
- steps:
18
- - yarn@0.1:
19
- inputs:
20
- - command: semantic-release
21
- title: Publish from alpha branch (... if needed)
22
- Master:
23
- before_run:
24
- - Primary
25
- steps:
26
- - yarn@0.0.8:
27
- inputs:
28
- - command: semantic-release
29
- title: Publish (... if needed)
30
- Primary:
31
- steps:
32
- - activate-ssh-key@4.1:
33
- run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
34
- - git-clone@6.1: {}
35
- - nvm@1.3: {}
36
- - yarn@0.1:
37
- title: Install Dependencies
38
- - yarn@0.1:
39
- title: Run Linting
40
- inputs:
41
- - command: lint
42
- - yarn@0.1:
43
- title: Run typechecking
44
- inputs:
45
- - command: tsc -p src --noEmit
46
- - yarn@0.1:
47
- inputs:
48
- - command: test
49
- title: Run Tests
50
- PullRequests:
51
- before_run:
52
- - Primary
53
- steps:
54
- - script@1.1.5:
55
- inputs:
56
- - content: >
57
- #!/bin/bash
58
-
59
- set -ex
60
-
61
-
62
- # Check for malformed commit messages
63
-
64
- git log --pretty=format:'%s' origin/master...$BITRISE_GIT_COMMIT |
65
- yarn commitlint
66
- title: Lint Commits
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- extends: ['@commitlint/config-conventional'],
3
- // https://commitlint.js.org/#/reference-rules
4
- rules: {
5
- 'header-max-length': [0],
6
- 'scope-case': [2, 'always', ['lower-case', 'camel-case', 'pascal-case']],
7
- 'subject-case': [0],
8
- 'subject-full-stop': [0],
9
- },
10
- };
package/jest.setup.js DELETED
@@ -1,36 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- const Enzyme = require('enzyme');
3
- const Adapter = require('@wojtekmaj/enzyme-adapter-react-17');
4
- const { JSDOM } = require('jsdom');
5
-
6
- const jsdom = new JSDOM('<!doctype html><html><body></body></html>', {
7
- url: 'http://localhost/',
8
- });
9
- const { window } = jsdom;
10
-
11
- Object.defineProperty(window, 'matchMedia', {
12
- value: () => ({
13
- matches: false,
14
- addListener: () => {},
15
- removeListener: () => {},
16
- }),
17
- });
18
-
19
- global.window = window;
20
- global.document = window.document;
21
- global.navigator = {
22
- userAgent: 'node.js',
23
- };
24
-
25
- global.requestAnimationFrame = (cb) => setTimeout(cb, 0);
26
- global.cancelAnimationFrame = (id) => clearTimeout(id);
27
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
28
- global.window.requestAnimationFrame = (cb) => setTimeout(cb, 0);
29
- global.window.cancelAnimationFrame = (id) => clearTimeout(id);
30
-
31
- Object.defineProperties(global, {
32
- ...Object.getOwnPropertyDescriptors(window),
33
- ...Object.getOwnPropertyDescriptors(global),
34
- });
35
-
36
- Enzyme.configure({ adapter: new Adapter() });
package/netlify.toml DELETED
@@ -1,42 +0,0 @@
1
- [Settings]
2
- [build]
3
- [[headers]]
4
- for = "*"
5
- [headers.values]
6
- Cache-Control = "no-cache, no-store, must-revalidate"
7
- [[headers]]
8
- for = "*.js"
9
- [headers.values]
10
- Cache-Control = "public, max-age=604800"
11
- [[headers]]
12
- for = "*.css"
13
- [headers.values]
14
- Cache-Control = "public, max-age=604800"
15
- [[headers]]
16
- for = "*.eot"
17
- [headers.values]
18
- Cache-Control = "public, max-age=604800"
19
- [[headers]]
20
- for = "*.png"
21
- [headers.values]
22
- Cache-Control = "public, max-age=604800"
23
- [[headers]]
24
- for = "*.svg"
25
- [headers.values]
26
- Cache-Control = "public, max-age=604800"
27
- [[headers]]
28
- for = "*.ttf"
29
- [headers.values]
30
- Cache-Control = "public, max-age=604800"
31
- [[headers]]
32
- for = "*.woff"
33
- [headers.values]
34
- Cache-Control = "public, max-age=604800"
35
- [[headers]]
36
- for = "*.woff2"
37
- [headers.values]
38
- Cache-Control = "public, max-age=604800"
39
- [[redirects]]
40
- from = "/*"
41
- to = "/index.html"
42
- status = 200
package/postcss.config.js DELETED
@@ -1,16 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- const autoprefixer = require('autoprefixer');
3
- const postcssPresetEnv = require('postcss-preset-env');
4
-
5
- module.exports = {
6
- plugins: [
7
- autoprefixer(),
8
- postcssPresetEnv({
9
- stage: 3,
10
- features: {
11
- 'custom-properties': false,
12
- 'nesting-rules': true,
13
- },
14
- }),
15
- ],
16
- };
package/release.config.js DELETED
@@ -1,32 +0,0 @@
1
- module.exports = {
2
- branches: ['master', { name: 'alpha', prerelease: true }, { name: 'alpha-*', prerelease: true }],
3
- plugins: [
4
- [
5
- '@semantic-release/commit-analyzer',
6
- {
7
- releaseRules: [
8
- { breaking: true, release: 'major' },
9
- { type: 'feat', release: 'minor' },
10
- { type: 'fix', release: 'patch' },
11
- { type: 'perf', release: 'patch' },
12
- { type: 'style', release: 'patch' },
13
- { type: 'chore', release: 'patch' },
14
- ],
15
- },
16
- ],
17
- '@semantic-release/release-notes-generator',
18
- '@semantic-release/npm',
19
- '@semantic-release/github',
20
- ],
21
- verifyConditions: ['@semantic-release/changelog', '@semantic-release/npm', '@semantic-release/git'],
22
- prepare: [
23
- '@semantic-release/changelog',
24
- '@semantic-release/npm',
25
- {
26
- path: '@semantic-release/git',
27
- assets: ['CHANGELOG.md'],
28
- // eslint-disable-next-line no-template-curly-in-string
29
- message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
30
- },
31
- ],
32
- };
package/renovate.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "local>bitrise-io/renovate-config"
5
- ]
6
- }
@@ -1,7 +0,0 @@
1
- import path from 'path';
2
- import watch from 'node-watch';
3
- import buildDocs from './build-docs';
4
-
5
- watch(path.resolve(__dirname, '../src'), { recursive: true }, () => {
6
- buildDocs();
7
- });
@@ -1,59 +0,0 @@
1
- /* eslint-disable no-console */
2
-
3
- import path from 'path';
4
- import fs from 'fs';
5
- import { parse, DocumentationObject } from 'react-docgen';
6
- import ts from 'typescript';
7
-
8
- const documentation: { [key: string]: DocumentationObject } = {};
9
- const exportedComponents: { [key: string]: string } = {};
10
- const indexFile = path.resolve(__dirname, '../src/index.ts');
11
- const indexFileContent = fs.readFileSync(indexFile, 'utf8');
12
- const indexSourceFile = ts.createSourceFile('index.ts', indexFileContent, ts.ScriptTarget.ES2015, true);
13
-
14
- const exclude = ['Portal'];
15
-
16
- const getExportedComponents = (node: ts.Node) => {
17
- if (node.kind === ts.SyntaxKind.ExportDeclaration) {
18
- const decl = node as ts.ExportDeclaration;
19
-
20
- if (decl.exportClause) {
21
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
22
- // @ts-ignore
23
- const defaultExport = decl.exportClause.elements.find(
24
- ({ propertyName }: { propertyName: any }) => !!propertyName && propertyName.getText() === 'default',
25
- );
26
-
27
- if (decl.moduleSpecifier && defaultExport) {
28
- exportedComponents[defaultExport.name.getText()] = (decl.moduleSpecifier as unknown as { text: string }).text;
29
- }
30
- }
31
- }
32
-
33
- ts.forEachChild(node, (n) => getExportedComponents(n));
34
- };
35
-
36
- const buildDocs = () => {
37
- getExportedComponents(indexSourceFile);
38
-
39
- Object.entries(exportedComponents)
40
- .filter(([exportName]) => !exclude.includes(exportName))
41
- .forEach(([exportName, exportPath]) => {
42
- try {
43
- const filePath = path.resolve(__dirname, '../src', `${exportPath}.tsx`);
44
- const fileContent = fs.readFileSync(filePath, 'utf8');
45
- const parsedDocs = parse(fileContent);
46
-
47
- documentation[exportName] = parsedDocs;
48
- } catch (e) {
49
- console.error(`${exportName}: ${exportPath}`);
50
- console.error(e);
51
- }
52
- });
53
-
54
- fs.writeFileSync(path.resolve(__dirname, '../documentation.json'), JSON.stringify(documentation, null, 2));
55
- };
56
-
57
- buildDocs();
58
-
59
- export default buildDocs;
Binary file
Binary file
@@ -1,87 +0,0 @@
1
- pre[class*='language-'] {
2
- width: 100%;
3
- color: var(--color-gray--1);
4
- overflow: auto;
5
- }
6
-
7
- pre[class*='language-'],
8
- code[class*='language-'] {
9
- font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
10
- font-size: var(--fontSizes-2);
11
- text-align: left;
12
- line-height: var(--lineHeights-2);
13
- white-space: pre;
14
- word-spacing: normal;
15
- hyphens: none;
16
- word-break: normal;
17
- word-wrap: normal;
18
- tab-size: 2;
19
- }
20
-
21
- /* stylelint-disable selector-class-pattern, font-weight-notation */
22
- .token.comment,
23
- .token.prolog,
24
- .token.doctype,
25
- .token.cdata {
26
- color: var(--color-gray--5);
27
- }
28
-
29
- .token.tag {
30
- color: var(--color-red--1);
31
- }
32
-
33
- .token.punctuation {
34
- color: var(--color-gray--3);
35
- }
36
-
37
- .token.function,
38
- .token.attr-name,
39
- .token.selector {
40
- color: var(--color-aqua--3);
41
- }
42
-
43
- .token.string {
44
- color: var(--color-green--3);
45
- }
46
-
47
- .token.attr-value,
48
- .token.boolean,
49
- .token.keyword,
50
- .token.number,
51
- .token.property {
52
- color: var(--color-grape--2);
53
- }
54
-
55
- .token.function {
56
- color: var(--color-yellow--3);
57
- }
58
-
59
- /*
60
- .token.regex,
61
- .token.important,
62
- .token.variable,
63
- .token.atrule,
64
- .token.char,
65
- .token.builtin,
66
- .token.inserted,,
67
- .token.property,
68
- .token.boolean,
69
- .token.number,
70
- .token.constant,
71
- .token.symbol,
72
- .token.deleted,
73
- */
74
-
75
- .token.important,
76
- .token.bold {
77
- font-weight: 700;
78
- }
79
-
80
- .token.italic {
81
- font-style: italic;
82
- }
83
-
84
- .token.entity {
85
- cursor: help;
86
- }
87
- /* stylelint-enable */
@@ -1,35 +0,0 @@
1
- import * as React from 'react';
2
- import * as Prism from 'prismjs';
3
- import { Base, FlexProps } from '@bitrise/bitkit';
4
- import Window from '../Window/Window';
5
- import 'prismjs/components/prism-jsx';
6
- import './CodeBlock.css';
7
-
8
- const { useEffect, useState } = React;
9
-
10
- interface Props extends FlexProps {
11
- children: string;
12
- language?: 'css' | 'jsx';
13
- title: string;
14
- }
15
-
16
- const CodeBlock: React.FunctionComponent<Props> = (props: Props) => {
17
- const { children, language = 'jsx', title, ...rest } = props;
18
- const [__html, setCode] = useState<string>('');
19
-
20
- useEffect(() => {
21
- setCode(Prism.highlight(children || '', Prism.languages[language], language));
22
- }, [children]);
23
-
24
- return (
25
- <Window {...rest} backgroundColor="grape-5" margin="x12" textColor="grape-1" title={title}>
26
- <Base paddingHorizontal="x4" paddingVertical="x3">
27
- <pre className={`language-${language}`}>
28
- <code dangerouslySetInnerHTML={{ __html }} />
29
- </pre>
30
- </Base>
31
- </Window>
32
- );
33
- };
34
-
35
- export default CodeBlock;
@@ -1,150 +0,0 @@
1
- import * as React from 'react';
2
- import { match, Link as RouterLink, Redirect } from 'react-router-dom';
3
- import { DocumentationObject, PropDescriptor } from 'react-docgen';
4
- import { Base, Flex, FlexProps, Link, Notification, Text } from '@bitrise/bitkit';
5
- import PropsTable from '../PropsTable/PropsTable';
6
-
7
- interface Props extends FlexProps {
8
- match: match<{
9
- sectionName: string;
10
- }>;
11
- map: {
12
- [key: string]: {
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- Showcase?: React.ComponentType<any>;
15
- components: DocumentationObject[];
16
- information?: string;
17
- };
18
- };
19
- }
20
-
21
- const filterProps = ([name, value]: [string, PropDescriptor]) =>
22
- value.description !== '@Ignore' && name !== 'className' && name !== 'ref' && name !== 'style';
23
-
24
- const ComponentDocumentation = (props: Props): JSX.Element => {
25
- const {
26
- match: { params },
27
- map,
28
- } = props;
29
- const { sectionName } = params;
30
- const key = Object.keys(map).find((k) => !!k.match(new RegExp(sectionName, 'i')));
31
-
32
- if (!key || !map[key]) {
33
- return <Redirect to="/components/404" />;
34
- }
35
-
36
- const { Showcase, components, information } = map[key];
37
- const componentsFilteredProps = components.reduce((properties, component) => {
38
- if (!component) {
39
- return {
40
- ...properties,
41
- };
42
- }
43
- return {
44
- ...properties,
45
- [component.displayName]: Object.entries(component.props || {}).filter(filterProps),
46
- };
47
- }, {});
48
-
49
- return (
50
- <Flex>
51
- <Text margin="x6" size="8" weight="bold">
52
- {key}
53
- </Text>
54
-
55
- {information && (
56
- <Notification icon="Info" type="inform">
57
- {information}
58
- </Notification>
59
- )}
60
-
61
- <Base margin="x16">
62
- <Text margin="x2" size="4" weight="bold">
63
- Components summary
64
- </Text>
65
-
66
- {components.map((c) => {
67
- if (!c) {
68
- return;
69
- }
70
- const { description, displayName } = c;
71
- return (
72
- <Base key={displayName} margin="x4">
73
- <Link Component={RouterLink} color="grape-3" to={`#${displayName}`}>
74
- {displayName}
75
- </Link>
76
- {description && <Text size="2">{description}</Text>}
77
- {!!componentsFilteredProps[displayName].length && (
78
- <Text margin="x1" size="2">
79
- Props:{' '}
80
- {componentsFilteredProps[displayName].map(([propName], index, { length }) => (
81
- <Link Component={RouterLink} color="gray-5" key={propName} to={`#${displayName}-${propName}`}>
82
- {propName + (index + 1 === length ? '' : ' / ')}
83
- </Link>
84
- ))}
85
- </Text>
86
- )}
87
- </Base>
88
- );
89
- })}
90
- </Base>
91
-
92
- {Showcase && (
93
- <Base margin="x16">
94
- <Text margin="x2" size="4" weight="bold">
95
- Showcase
96
- </Text>
97
- <Showcase />
98
- </Base>
99
- )}
100
-
101
- <Base margin="x16">
102
- <Text margin="x2" size="4" weight="bold">
103
- Components API
104
- </Text>
105
-
106
- {components.map((c) => {
107
- if (!c) {
108
- return;
109
- }
110
- const { composes, description, displayName } = c;
111
- return (
112
- <Base id={displayName} key={displayName} margin="x8">
113
- <Flex direction="horizontal">
114
- <Flex grow initial="none">
115
- <Text>{`<${displayName}>`}</Text>
116
- {description && <Text size="2">{description}</Text>}
117
- </Flex>
118
-
119
- {composes && composes.length && (
120
- <Flex>
121
- <Text>
122
- Extends:{' '}
123
- {composes
124
- .map((compose) => compose.replace('Props', ''))
125
- .map((compose) => (
126
- <Link key={compose} to={`/documentation/components/${compose}`}>{`<${compose}>`}</Link>
127
- ))}
128
- </Text>
129
- </Flex>
130
- )}
131
- </Flex>
132
-
133
- <PropsTable
134
- composes={composes}
135
- displayName={displayName}
136
- margin="x4"
137
- props={componentsFilteredProps[displayName].reduce(
138
- (props, [name, value]) => ({ ...props, [name]: value }),
139
- {},
140
- )}
141
- />
142
- </Base>
143
- );
144
- })}
145
- </Base>
146
- </Flex>
147
- );
148
- };
149
-
150
- export default ComponentDocumentation;