Skip to content

Commit

Permalink
docs(installation): align instructions between frameworks (#1282)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Maurer <[email protected]>
  • Loading branch information
danielleroux and nuke-ellington committed Jun 17, 2024
1 parent 9577742 commit 5c80062
Show file tree
Hide file tree
Showing 21 changed files with 770 additions and 415 deletions.
40 changes: 24 additions & 16 deletions packages/documentation/docs/installation/angular.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,30 @@ sidebar_position: 1
sidebar_title: Angular
title: Angular
---

### Install dependencies

Install `@siemens/ix-angular` and `@siemens/ix-icons` using a package manager:

#### npm

```
npm i -S @siemens/ix-angular @siemens/ix-icons
```

#### yarn

```
yarn add @siemens/ix-angular @siemens/ix-icons
```
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

### Library installation

Install `@siemens/ix`, `@siemens/ix-angular` and `@siemens/ix-icons` using a package manager:

<Tabs>
<TabItem value="npm" label="NPM" default>
```
npm install @siemens/ix @siemens/ix-angular @siemens/ix-icons
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```
yarn add @siemens/ix @siemens/ix-angular @siemens/ix-icons
```
</TabItem>
<TabItem value="pnpm" label="PNPM">
```
pnpm add @siemens/ix @siemens/ix-angular @siemens/ix-icons
```
</TabItem>
</Tabs>

### Import styles

Expand Down
42 changes: 24 additions & 18 deletions packages/documentation/docs/installation/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,31 @@ sidebar_position: 3
sidebar_title: Web Components
title: Web Components
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import Playground from '@site/src/components/PlaygroundV2';

## Installation
### Library installation

Install `@siemens/ix` and `@siemens/ix-icons` using a package manager:

### npm

```
npm i -S @siemens/ix @siemens/ix-icons
```

### yarn

```
yarn add @siemens/ix @siemens/ix-icons
```
<Tabs>
<TabItem value="npm" label="NPM" default>
```
npm install @siemens/ix @siemens/ix-icons
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```
yarn add @siemens/ix @siemens/ix-icons
```
</TabItem>
<TabItem value="pnpm" label="PNPM">
```
pnpm add @siemens/ix @siemens/ix-icons
```
</TabItem>
</Tabs>

## Build

Expand Down Expand Up @@ -50,13 +57,12 @@ In the following section we will describe how you can build an application with

```javascript
import '@siemens/ix/dist/siemens-ix/siemens-ix.css';
import { applyPolyfills, defineCustomElements } from '@siemens/ix/loader';
import { defineCustomElements as ixIconsDefineCustomElements } from '@siemens/ix-icons/loader';
import { defineCustomElements } from '@siemens/ix/loader';
import { defineCustomElements as defineIxIconCustomElement } from '@siemens/ix-icons/loader';

(async () => {
await applyPolyfills();
await ixIconsDefineCustomElements();
await defineCustomElements();
defineIxIconCustomElement();
defineCustomElements();
})();
```

Expand Down
40 changes: 24 additions & 16 deletions packages/documentation/docs/installation/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,30 @@ sidebar_position: 2
sidebar_title: React
title: React
---

### Install dependencies

Install `@siemens/ix-react` and `@siemens/ix-icons` using a package manager:

#### npm

```
npm i -S @siemens/ix-react @siemens/ix-icons
```

#### yarn

```
yarn add @siemens/ix-react@latest @siemens/ix-icons
```
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

### Library installation

Install `@siemens/ix`, `@siemens/ix-react` and `@siemens/ix-icons` using a package manager:

<Tabs>
<TabItem value="npm" label="NPM" default>
```
npm install @siemens/ix @siemens/ix-react @siemens/ix-icons
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```
yarn add @siemens/ix @siemens/ix-react @siemens/ix-icons
```
</TabItem>
<TabItem value="pnpm" label="PNPM">
```
pnpm add @siemens/ix @siemens/ix-react @siemens/ix-icons
```
</TabItem>
</Tabs>

### Import styles

Expand Down
38 changes: 23 additions & 15 deletions packages/documentation/docs/installation/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ sidebar_position: 4
sidebar_title: Vue
title: Vue
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

:::caution Experimental disclaimer

Expand All @@ -12,21 +14,27 @@ Nevertheless feedback of any kind will be helpful.

:::

### Install dependencies

Install `@siemens/ix-vue` and `@siemens/ix-icons` using a package manager:

#### npm

```
npm i -S @siemens/ix-vue @siemens/ix-icons
```

#### yarn

```
yarn add @siemens/ix-vue@latest @siemens/ix-icons
```
### Library installation

Install `@siemens/ix`, `@siemens/ix-vue` and `@siemens/ix-icons` using a package manager:

<Tabs>
<TabItem value="npm" label="NPM" default>
```
npm install @siemens/ix @siemens/ix-vue @siemens/ix-icons
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```
yarn add @siemens/ix @siemens/ix-vue @siemens/ix-icons
```
</TabItem>
<TabItem value="pnpm" label="PNPM">
```
pnpm add @siemens/ix @siemens/ix-vue @siemens/ix-icons
```
</TabItem>
</Tabs>

### Usage

Expand Down
16 changes: 8 additions & 8 deletions packages/documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
"generate-changelog": "ts-node -P ./scripts/tsconfig.json ./scripts/generate-changelog.ts"
},
"dependencies": {
"@docusaurus/core": "3.1.0",
"@docusaurus/preset-classic": "3.1.0",
"@docusaurus/theme-live-codeblock": "3.1.0",
"@docusaurus/core": "3.3.2",
"@docusaurus/preset-classic": "3.3.2",
"@docusaurus/theme-live-codeblock": "3.3.2",
"@mdx-js/react": "^3.0.0",
"@siemens/ix": "workspace:*",
"@siemens/ix-echarts": "workspace:*",
"@siemens/ix-icons": "2.1.0",
"@siemens/ix-icons": "^2.0.0",
"@siemens/ix-react": "workspace:*",
"@stackblitz/sdk": "^1.8.1",
"clsx": "^1.2.1",
"docusaurus-lunr-search": "^2.3.2",
"docusaurus-lunr-search": "^3.4.0",
"docusaurus-plugin-sass": "^0.2.2",
"execa": "^5.1.1",
"html-test-app": "workspace:*",
Expand All @@ -42,9 +42,9 @@
"sass": "^1.54.8"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.1.0",
"@docusaurus/tsconfig": "3.1.0",
"@docusaurus/types": "3.1.0",
"@docusaurus/module-type-aliases": "3.3.2",
"@docusaurus/tsconfig": "3.3.2",
"@docusaurus/types": "3.3.2",
"@types/fs-extra": "^9.0.13",
"@types/rimraf": "^3.0.2",
"@types/tar": "^6.1.7",
Expand Down
11 changes: 6 additions & 5 deletions packages/documentation/src/components/FrameworkSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* LICENSE file in the root directory of this source tree.
*/

import { IxSelect, IxSelectItem } from '@siemens/ix-react';
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';

export default function FrameworkSelection(): JSX.Element {
Expand Down Expand Up @@ -35,18 +36,18 @@ export default function FrameworkSelection(): JSX.Element {
}, [ref]);

return (
<ix-select
<IxSelect
ref={ref}
default-value={framework}
style={{
width: '100%',
}}
>
<ix-select-item
<IxSelectItem
value="webcomponent"
label="Webcomponent"
></ix-select-item>
<ix-select-item value="angular" label="Angular"></ix-select-item>
</ix-select>
></IxSelectItem>
<IxSelectItem value="angular" label="Angular"></IxSelectItem>
</IxSelect>
);
}
7 changes: 4 additions & 3 deletions packages/documentation/src/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ICON_LIST from '@siemens/ix-icons/dist/sample.json';
import clsx from 'clsx';
import React, { useRef, useState } from 'react';
import styles from './Icons.module.css';
import { IxIcon } from '@siemens/ix-react';

const Icons: React.FC = () => {
const refs = useRef<{ [k: string]: any }>({});
Expand Down Expand Up @@ -38,10 +39,10 @@ const Icons: React.FC = () => {
<div
key={icon}
className={clsx(styles.Icon__Tile)}
onClick={() => {}}
onClick={() => { }}
>
<div>
<ix-icon name={icon}></ix-icon>
<IxIcon name={icon}></IxIcon>
</div>
<input
ref={(r) => {
Expand All @@ -51,7 +52,7 @@ const Icons: React.FC = () => {
type="text"
readOnly
value={icon}
onChange={() => {}}
onChange={() => { }}
></input>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function SourceCodePreview(props: {
let filesToFetch = [];

if (props.framework === TargetFramework.ANGULAR) {
filesToFetch = [`${props.name}.ts`, `${props.name}.html`];
filesToFetch.push(...[`${props.name}.html`, `${props.name}.ts`]);
}

if (props.framework === TargetFramework.JAVASCRIPT) {
Expand Down
32 changes: 13 additions & 19 deletions packages/documentation/src/components/SwitchTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import { ThemeChangeEvent } from '../utils/theme-change-event';
import { getDefaultTheme } from './config';
import styles from './SwitchTheme.module.css';

function applyThemeToBody(themes: string[], theme: string) {
themes.forEach((t) => document.body.classList.remove(t));

setTimeout(() => document.body.classList.add(theme), 0)
}

function ThemeEntry(props: {
label: string;
color: string;
Expand Down Expand Up @@ -57,21 +63,6 @@ export function SwitchTheme(props: {
},
]);

useEffect(() => {
let storedTheme = localStorage.getItem('theme');

if (!storedTheme) {
const theme = getDefaultTheme(context);
setTheme(theme);
localStorage.setItem('theme', theme);
storedTheme = theme;
} else {
setTheme(storedTheme);
}

document.body.className = storedTheme;
}, []);

useEffect(() => {
if (context.siteConfig.customFields.withBrandTheme) {
setRegisteredThemes([
Expand All @@ -88,16 +79,19 @@ export function SwitchTheme(props: {
},
]);
}

let storedTheme = window.localStorage.getItem('docusaurus-theme');

onThemeChange(storedTheme || getDefaultTheme(context));
}, []);

const onThemeChange = (theme: string) => {
setTheme(theme);
localStorage.setItem('theme', theme);
document.body.className = theme;

window.localStorage.setItem('docusaurus-theme', theme);
dispatchThemeChange(theme);

setOpen(false);

applyThemeToBody(registeredThemes.map((t) => t.id), theme);
};

function getLabel(id: string = 'theme-classic-dark') {
Expand Down
Loading

0 comments on commit 5c80062

Please sign in to comment.