Skip to content

Commit

Permalink
feat: move theme logic to modules and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hrynevychroman committed Feb 1, 2024
1 parent f8776af commit 2425b21
Show file tree
Hide file tree
Showing 22 changed files with 1,145 additions and 708 deletions.
12 changes: 12 additions & 0 deletions docs/.vitepress/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default defineConfig({
'/guide/': { base: '/guide/', items: sidebarGuide() },
'/config/': { base: '/config/', items: sidebarGuide() },
'/types/': { base: '/types/', items: sidebarGuide() },
'/styles/': { base: '/styles/', items: sidebarGuide() },
},

socialLinks: [
Expand Down Expand Up @@ -102,6 +103,17 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] {
{ text: 'Dark', link: 'theme-dark' },
{ text: 'Smooth', link: 'theme-smooth' },
{ text: 'Contrast', link: 'theme-contrast' },
{ text: 'Custom', link: 'theme-custom' },
],
},
{
text: 'Styles',
base: '/styles/',
items: [
{ text: 'General', link: 'general' },
// { text: 'Typography', link: 'typography' },
// { text: 'Buttons', link: 'buttons' },
// { text: 'Layout', link: 'layout' },
],
},
{
Expand Down
7 changes: 7 additions & 0 deletions docs/config/shared-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,10 @@ Parameters that define the custom cookies.
- **Reference:** [Callback Functions](./callback-functions.md)

Functions that will be invoked after some events: first load, every load, after accepting cookies, and after rejecting cookies. Callback functions allow us to control the actions that must be executed depending on the state of the cookies.

## theme

- **Type:** `darkTheme | contrastTheme | smoothTheme | undefined`
- **Default:** `undefined`

Theme that will be applied to the cookies consent. Need to import module and add to the configuration.
21 changes: 7 additions & 14 deletions docs/guide/theme-contrast.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,18 @@

Contrast theme is a simple theme that is designed to be a starting point for your own customizations.

## Installation
## Usage

You need to import this css files `before` the main CSS file.
```typescript
import { CookiesConsent, contrastTheme } from '../index'

::: code-group
const cookiesConsent = new CookiesConsent({
// other configurations

```postcss [postcss]
@import '@metamorfosilab/cookies-consent/dist/themes/contrast.css';
theme: contrastTheme, // [!code highlight]
})
```

```scss [scss]
@import '~@metamorfosilab/cookies-consent/dist/themes/contrast.css';
```

```css [css]
@import '@metamorfosilab/cookies-consent/dist/themes/contrast.css';
```
:::

## Preview

![Contrast Theme](../assets/images/themes/cc-theme-contrast.jpeg)
Expand Down
5 changes: 5 additions & 0 deletions docs/guide/theme-custom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Custom Theme

To make CookiesConsent look like your website, you can create your own theme. just pass your theme object to the `theme` property of the configuration object.

Please refer to the [Styles API](../styles/general.md) for more information.
21 changes: 7 additions & 14 deletions docs/guide/theme-dark.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,18 @@

Dark theme is a simple theme that is designed to be a starting point for your own customizations.

## Installation
## Usage

You need to import this css files `before` the main CSS file.
```typescript
import { CookiesConsent, darkTheme } from '../index'

::: code-group
const cookiesConsent = new CookiesConsent({
// other configurations

```postcss [postcss]
@import '@metamorfosilab/cookies-consent/dist/themes/dark.css';
theme: darkTheme, // [!code highlight]
})
```

```scss [scss]
@import '~@metamorfosilab/cookies-consent/dist/themes/dark.css';
```

```css [css]
@import '@metamorfosilab/cookies-consent/dist/themes/dark.css';
```
:::

## Preview

![Dark Theme](../assets/images/themes/cc-theme-dark.jpeg)
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/theme-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The default theme is a simple theme that is designed to be a starting point for

## Installation

For this theme, you don't need to import any CSS file. It's already included in the main CSS file.
For this theme, you don't need to specify `theme` property in the configuration object.

## Preview

Expand Down
21 changes: 7 additions & 14 deletions docs/guide/theme-smooth.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,18 @@

Smooth theme is a simple theme that is designed to be a starting point for your own customizations.

## Installation
## Usage

You need to import this css files `before` the main CSS file.
```typescript
import { CookiesConsent, smoothTheme } from '../index'

::: code-group
const cookiesConsent = new CookiesConsent({
// other configurations

```postcss [postcss]
@import '@metamorfosilab/cookies-consent/dist/themes/smooth.css';
theme: smoothTheme, // [!code highlight]
})
```

```scss [scss]
@import '~@metamorfosilab/cookies-consent/dist/themes/smooth.css';
```

```css [css]
@import '@metamorfosilab/cookies-consent/dist/themes/smooth.css';
```
:::

## Preview

![Smooth Theme](../assets/images/themes/cc-theme-smooth.jpeg)
Expand Down
Loading

0 comments on commit 2425b21

Please sign in to comment.