Skip to content

Commit

Permalink
feat: documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
mauroerta committed Aug 8, 2021
1 parent 3dc6300 commit 2bf10e7
Show file tree
Hide file tree
Showing 34 changed files with 1,669 additions and 416 deletions.
135 changes: 57 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,103 +19,82 @@

Morfeo it's a tool to build design systems based on a theme.

It helps you to _follow a design language_ and write consistent UIs, whatever it is the framework of your choice.
It helps you to _follow a design language_ and write consistent UIs, whatever is the framework of your choice.

It's easy to use and, with the **browser extension**, your theme and your components are automatically documented.
It's easy to use and, with the [**browser extension**](https://chrome.google.com/webstore/detail/morfeo/phhhjdmeicikchjnpepljcdgbmipipcl), your theme and your components are automagically documented.

## Features

- [Framework Agnostic](https://morfeo.dev/docs/Introduction/framework-agnostic)
- [Single source of truth](https://morfeo.dev/docs/Introduction/single-source-of-truth)
- [Dev Tool](https://morfeo.dev/docs/Introduction/dev-tool)
- [Extendible](https://morfeo.dev/docs/Introduction/extendible)
- [Easy to test](https://morfeo.dev/docs/Introduction/easy-to-testhttps://morfeo.dev/docs/Introduction/easy-to-test)
- [Framework Agnostic](https://morfeo.dev/docs/Features/framework-agnostic)
- [Single source of truth](https://morfeo.dev/docs/single-source-of-truth.mdx)
- [Multi theming](https://morfeo.dev/docs/Features/multi-theming)
- [Dev Tool](https://morfeo.dev/docs/Features/dev-tool.mdx)
- [CLI](https://morfeo.dev/docs/Features/morfeo-cli.mdx)
- [Extendible](https://morfeo.dev/docs/Features/extendible.mdx)
- [Easy to test](https://morfeo.dev/docs/Features/easy-to-test.mdx)

## How it works

The main concepts around morfeo are 2 entities, **theme** and **parsers**:
You can start using morfeo in 30 seconds:

`theme` it's an handler that contains the **design language** of your application, for example a set of colors, spacings, shadows, sizes and gradients, and the base style of your components.
- install

An example of theme could be the following:
```bash
# or @morfeo/(react | svelte | native | web) depending on your framework of choice
npm i @morfeo/core
# or with yarn
yarn add @morfeo/core
```

```typescript
import { theme } from '@morfeo/core';
- set the theme (you can create your own or use our [preset](../Packages/preset-default.mdx))

const defaultTheme = {
color: {
primary: '#000',
secondary: '#e3e3e3',
danger: '#eb2f06',
success: '#78e08f',
warning: '#fa983a',
},
space: {
xxs: '8px',
xs: '16px',
s: '24px',
m: '32px',
l: '40px',
xl: '48px',
xxl: '56px',
},
components: {
Button: {
style: {
color: 'primary',
padding: 's',
},
},
},
};
```typescript
import { morfeo } from '@morfeo/core';
import { darkTheme, lightTheme } from './themes';

// From now on the theme will be available in all your application
theme.set(defaultTheme);
morfeo.setTheme('light', lightTheme);
morfeo.setTheme('dark', darkTheme);
```

console.log(theme.get()); // will log an object equals to `defaultTheme`
console.log(theme.getValue('colors', 'primary')); // will log #000
```
or simply:

Once you have a centralized theme, you need to parse this theme to generate the style for your components an layouts, here is where the `parsers` handler start to play!
```typescript
// automatically adds two default light and dark themes.
import '@morfeo/preset-default';
```

This is an example with React
- Use it everywhere to resolve a [morfeo style object](https://morfeo.dev/docs/theme-specification#morfeo-style-object) into a valid `css-in-js` object:

```tsx
import { parsers } from '@morfeo/core';
```tsx
import { morfeo } from '@morfeo/core';

function Button() {
const style = parsers.resolve({ componentName: 'Button' });
/**
* {
* "paddingLeft": "40px",
* "paddingRight": "40px"
* "borderRadius": "50%"
* "background-color": "#06f"
* }
*/
const style = morfeo.resolve({
px: 'l',
corner: 'round',
bg: 'primary',
});
```

return <button style={style}>Click me</button>;
}
```
Morfeo works everywhere, [no matter what's the framework or library you're using](https://morfeo.dev/docs/Features/framework-agnostic), not only as a `run time` parser but even as a static css generator thanks to our `CLI` ([@morfeo/cli](https://morfeo.dev/docs/Features/morfeo-cli)).

In the case of `React`, we built a package that suites it better: [@morfeo/react](../Packages/react)
Checkout all our packages and choose the one that fits better your needs:

```tsx
import { useStyle } from '@morfeo/react';
- [@morfeo/react](https://morfeo.dev/docs/Packages/react)
- [@morfeo/native](https://morfeo.dev/docs/Packages/native)
- [@morfeo/styled-components-web](https://morfeo.dev/docs/Packages/styled-components-web)
- [@morfeo/svelte](https://morfeo.dev/docs/Packages/svelte)
- [@morfeo/jss](https://morfeo.dev/docs/Packages/jss)
- And more ...

function Button() {
const style = useStyle({ componentName: 'Button' });
And even more are coming soon:

return <button style={style}>Click me</button>;
}
```

The value of `style` will be in this example equals to:

```json
{
"color": "#000",
"padding": "16px"
}
```

## Motivations

When your application starts to grow, maintain UI consistency it's not easy.
Even in popular applications we often face **wrong typographies**, different **color pallettes** used across different pages or inconsistent **spacings** in each component.

These problems are even more frequent in large applications where different teams works on different features (maybe with different technologies and frameworks).

**morfeo** solves this problem by sharing across all the application a customizable `theme` that contains the "language" of the application design and a `parser` that generate styles based on this language, in this way the UIs an the components are always consistent.
- _@morfeo/angular_ **coming soon**
- _@morfeo/styled-components-native_ **coming soon**
2 changes: 1 addition & 1 deletion docs/blog/2021-06-27-welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ There are a lot of ways you can help us to improve morfeo and grow as a communit

If you're a developer and you want to contribute [PRs are welcome!](https://github.com/VLK-STUDIO/morfeo)!
If you're not a developer or you don't want to contribute in this way, it could be extremely useful to know your thoughts about morfeo,
how we can improve the library, or just feedback. For this kind of contribution, we will always be available in the [slack channel](https://morfeo.slack.com/).
how we can improve the library, or just some feedback. For this kind of contribution, we will always be available in the [slack channel](https://morfeo.slack.com/).
42 changes: 42 additions & 0 deletions docs/blog/2021-08-08-cli-and.presets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
slug: cli-and-presets
title: 🎉 Introducing CLI and Preset 🎉
author: Mauro Erta
author_title: Front End Engineer @ VLK STUDIO
author_url: https://github.com/mauroerta
author_image_url: https://avatars.githubusercontent.com/u/13780027?v=4
tags: [cli, morfeo, design, system, preset]
---

Today we are going to release 2 new features:

- a CLI that generates static CSS based on the theme
- a theme preset to easily start using morfeo in 30 seconds (Many thanks to [Andrea](https://github.com/andreaSimonePorceddu) who made it possible)

### CLI

We are so happy to announce this new tool because it was one of the first feature we wanted to implement for morfeo!
You can find more info about it [here in the docs](/docs/Features/morfeo-cli).

### Theme preset

In this [pull-request](https://github.com/VLK-STUDIO/morfeo/pull/62), based on this [issue](https://github.com/VLK-STUDIO/morfeo/issues/45) my friend and colleague [Andrea](https://github.com/andreaSimonePorceddu) introduces a new packages called `@morfeo/preset-default`, this package contains 2 complete themes, one dark and one light, to easily start using morfeo without create a whole complete theme your own.

Checkout more info about the preset [here](/docs/Packages/preset-default).

### Work with us

More features are coming soon, we are close to finish the version 1 of morfeo, with your help we can go even faster!

If you want to help us improve morfeo, be sure you've read the [contributing](https://github.com/VLK-STUDIO/morfeo/blob/main/CONTRIBUTING.md) file.
There are a lot of ways you can help us to improve morfeo and grow as a community, for example:

- Improve documentation
- Add new functionalities
- [Fix a bug](https://github.com/VLK-STUDIO/morfeo/issues)
- Write an article about morfeo
- Give us a feedback

If you're a developer and you want to contribute [PRs are welcome!](https://github.com/VLK-STUDIO/morfeo)!
If you're not a developer or you don't want to contribute in this way, it could be extremely useful to know your thoughts about morfeo,
how we can improve the library, or just some feedback. For this kind of contribution, we will always be available in the [slack channel](https://morfeo.slack.com/).
103 changes: 103 additions & 0 deletions docs/docs/Features/cli.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
sidebar_position: 1
id: morfeo-cli
title: CLI
description: Features > CLI
---

If you don't need to generate style `run time` or you don't want to use `javascript` at all, but you still want to benefit the morfeo eco-system and a centralized theme,
the `morfeo CLI` is what you need!

Morfeo CLI has (for now) only one command called `build`, with this command you can generate CSS based on a theme.

## Example

```typescript title="theme.tsx"
const theme = {
colors: {
primary: '#1abc9c',
secondary: '#3498db',
},
...restOfTheTheme,
components: {
Button: {
...,
style: {
...,
bg: "primary",
},
variants: {
secondary: {
...,
style: {
bg: "secondary"
},
},
},
},
},
};
```

After running this command:

```bash
morfeo build theme.tsx --name="themeName"
```

Will generate the CSS:

```css
:root,
html[data-morfeo-theme='themeName'] {
/* all the other variables */
--colors-primary: #1abc9c;
--colors-secondary: #3498db;
}

html[data-morfeo-theme='themeName'] .morfeo-button {
background-color: var(--colors-primary);
}

html[data-morfeo-theme='themeName'] .morfeo-button-secondary {
background-color: var(--colors-secondary);
}
```

:::note
Notice that the generated css starts with `html[data-morfeo-theme="themeName"]`, this enables you to generate multiple css styles for different themes and still have multi-theming even in this case, make sure to put the data-attribute `data-morfeo-theme` in the html tag
:::

After this, you can include the generated style in your application and use it to stylize your component or in custom css classes:

```tsx
import 'path/to/generated/styles';

function Button() {
return <button className="morfeo-button" />;
}
```

an example in plain vanilla javascript could be the following

```typescript
const button = document.createElement('button');
button.classList.add('morfeo-button');
```

Or even in simple old school HTML:

```html
<html data-morfeo-theme="themeName">
<head>
<link rel="stylesheet" href="path/to/generated/styles" />
</head>
<body>
<button class="morfeo-button">No Javascript needed</button>
</body>
</html>
```

## Specification

The details about all the flags and the configurations of @morfeo/cli can be found in the packages section, [here](../Packages/cli.mdx).
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
sidebar_position: 4
id: dev-tool
title: Dev Tool
description: Introduction > Dev Tool
description: Features > Dev Tool
---

import Link from '@docusaurus/Link';

One of the most important feature of morfeo is the [dev-tool](https://chrome.google.com/webstore/detail/morfeo/phhhjdmeicikchjnpepljcdgbmipipcl),
with the dev tool yuo'always be able to see your theme and play with it.
with the dev tool you'll always be able to see your theme and play with it.

![dev tool](../../static/img/devtool/hero.jpeg)

## Installation

You can install the dev tool by going to chrome webstore and add it to your plugins:
You can install the dev tool by going to chrome web store and add it to your plugins:

<Link
className="button button--primary button--lg"
Expand Down Expand Up @@ -44,15 +44,15 @@ npm i @morfeo/dev-tools
yarn add @morfeo/dev-tools
```

the in your app, before setting the theme, just add:
then in your app, just call the function `enableMorfeoDevTool`:

```typescript
import { enableMorfeoDevTool } from '@morfeo/dev-tools';
import { myTheme } from './myTheme';

enableMorfeoDevTool();

theme.set(myTheme);
morfeo.setTheme('light', myTheme);
```

:::info
Expand All @@ -63,11 +63,11 @@ In a future release the dev tool will probably be always enabled by default

We want to improve the dev tool as much as possible and add functionalities like:

- change the application theme from the theme
- change the application theme from the dev tool
- increase the supported theme slices
- a UI to easily generate the style based on the theme
- theme storage to apply theme presets to your application
- handle multi-theming

If you want to help us, check our [GitHub](https://github.com/VLK-STUDIO/morfeo)!

If you want a particular funcionality or you found a bug, open an issue [here](https://github.com/VLK-STUDIO/morfeo/issues)
If you want a particular functionality or you found a bug, please, open an issue [here](https://github.com/VLK-STUDIO/morfeo/issues)
Loading

0 comments on commit 2bf10e7

Please sign in to comment.