Skip to content

Commit

Permalink
docs: improve README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Givanyan committed Feb 7, 2024
1 parent fb34ee9 commit 825dd07
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
42 changes: 37 additions & 5 deletions src/components/super/i-static-page/modules/theme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,24 @@ module.exports = config.createConfig({dirs: [__dirname, 'client']}, {

## Accessors

## current
### availableThemes

A set of available app themes.

```typescript
import iBlock, { component, prop, field } from 'components/super/i-block/i-block';

@component()
export default class bExample extends iBlock {
created() {
console.log(this.r.theme.availableThemes);
}
}
```

## Methods

### get

Current theme value.

Expand All @@ -103,22 +120,37 @@ import iBlock, { component, prop, field } from 'components/super/i-block/i-block
@component()
export default class bExample extends iBlock {
created() {
console.log(this.r.theme.current);
console.log(this.r.theme.get());
}
}
```

## availableThemes
### set

A set of available app themes.
Sets a new value for the current theme

```typescript
import iBlock, { component, prop, field } from 'components/super/i-block/i-block';

@component()
export default class bExample extends iBlock {
changeTheme(value: 'dark' | 'light') {
this.r.theme.set(value);
}
}
```

### useSystem

Sets the actual system theme and activates the system theme change listener

```typescript
import iBlock, { component, prop, field } from 'components/super/i-block/i-block';

@component()
export default class bExample extends iBlock {
created() {
console.log(this.r.theme.availableThemes);
this.r.theme.useSystem();
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ By default, the engine for the web is supported.
The engine needs to be passed to the `themeManager` constructor.

```ts
import { webEngineFactory } from 'core/system-theme-extractor/engines/web';
import { webEngineFactory } from 'components/super/i-static-page/modules/theme/system-theme-extractor/engines/web';

class iRoot extends iStaticPage {
@system<iStaticPage>((o) => themeManagerFactory(
Expand All @@ -24,8 +24,8 @@ class iRoot extends iStaticPage {
Also, you can implement your own engine.

```ts
// src/core/system-theme-extractor/engines/custom/index.ts
import type { SystemThemeExtractor } from 'core/system-theme-extractor';
// src/components/super/i-static-page/modules/theme/system-theme-extractor/engines/custom/index.ts
import type { SystemThemeExtractor } from 'components/super/i-static-page/modules/theme/system-theme-extractor';

export default class CustomEngine implements SystemThemeExtractor {
// Implement all necessary methods of the interface here.
Expand Down

0 comments on commit 825dd07

Please sign in to comment.