Skip to content

Commit

Permalink
feat: introduce uip-header reimplementation
Browse files Browse the repository at this point in the history
Reference for: ebeb66b

BREAKING CHANGE: `uip-header` and `uip-options` are removed. Use `uip-snippets` (`uip-snippets-list`, `uip-snippets-title`),
or combine it with buttons (`uip-copy`, `uip-theme-toggle`, `uip-direction-toggle`)
  • Loading branch information
ala-n committed Dec 13, 2023
1 parent 3a4aec8 commit 7c63ba5
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 57 deletions.
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ With the help of *UIP* components we allow user to *'play'* with a component.
You can choose from the variety of component's templates ([UIP Snippets](src/plugins/snippets-list/README.md)),
play with the component's settings ([UIP Settings](src/plugins/settings/README.md))
or even change its markup ([UIP Editor](src/plugins/editor/README.md))!
You can also manage Playground visual appearance by our options ([UIP Options](src/plugins/snippets/options/README.md))

Every element (except the *UIP Root*) isn't required, so you can combine them the way you want.

Expand All @@ -40,39 +39,41 @@ Import CSS styles

---
## UIP elements

⚠️ Documentation is in progress. You can find more information about each element in the corresponding README.md file. ⚠️

- ### Core
- #### [UIP Plugin](src/core/base/README.md#uip-plugin)
- #### [UIP Root](src/core/base/README.md#uip-root)
- #### [UIP State Model](src/core/base/README.md#uip-state-model)
- ### Components
- #### [UIP Preview](src/core/preview/README.md)
- ### Plugins
- #### [UIP Editor](src/plugins/editor/README.md)
- #### [UIP Header](src/plugins/snippets/README.md)
- ##### [UIP Snippets](src/plugins/snippets-list/README.md)
- ##### [UIP Options](src/plugins/snippets/options/README.md)
- ##### [UIP Snippets](src/plugins/snippets-list/README.md)
- ##### [UIP Snippets Title](src/plugins/snippets-list/README.md)
- ##### [UIP Snippets List](src/plugins/snippets-list/README.md)
- #### [UIP Settings](src/plugins/settings/README.md)
- ##### [UIP Setting](src/settings/setting/README.md)
- ##### [UIP Text Setting](src/plugins/settings/text-setting/README.md)
- ##### [UIP Bool Setting](src/plugins/settings/bool-setting/README.md)
- ##### [UIP Select Setting](src/plugins/settings/select-setting/README.md)
- #### [UIP Copy](src/plugins/copy/README.md)
- #### [UIP Theme Toggle](src/plugins/theme/README.md)
- #### [UIP Text Direction Toggle](src/plugins/direction/README.md)
---
## Example

![Example](docs/images/UIPexample2.png)

```html
<uip-root editor-collapsed>
<uip-header>
<uip-options></uip-options>
</uip-header>
<uip-root>
<uip-snippets class="uip-toolbar"></uip-snippets>
<script type="text/html" uip-snippet label="Logo">
<div class="logo-content gray-clr">
<img src="assets/uip-logo.png" alt="Logo">
<a class="get-started" href="{{ '/general/getting-started/'}}" data-test-msg="Get Started!"></a>
</div>
</script>
<uip-preview></uip-preview>
<uip-settings target=".logo-content">
<uip-settings vertical resizable target=".logo-content">
<uip-text-setting label="Alternative Button Text:" target=".get-started"
attribute="data-test-msg"></uip-text-setting>
<uip-slider-setting label="Width:" target=".logo-content img"
Expand All @@ -83,18 +84,15 @@ Import CSS styles
<option value="purple-clr">Purple</option>
</uip-select-setting>
</uip-settings>
<uip-editor collapsible></uip-editor>
</uip-root>
```

---

## Roadmap

- Integration with [ESL](https://github.com/exadel-inc/esl): demo pages
- Ability to control the width of Setting section
- Documentation and more demo content
- Css and JS support for Editor
- Readonly mode for Editor

---

Expand Down
36 changes: 8 additions & 28 deletions src/plugins/snippets-list/README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
# UIP Snippets
# UIP Snippets List

**UIPSnippets** - custom element which contains snippets (markup's templates). It allows users to see different predefined component's variations. Extends [UIPPlugin](src/core/README.md#uip-plugin).
**UIPSnippetsList** - custom element UIPPlugin to display a list of available snippets.

## Description

- Snippets should be placed in *template*/*script* tags, which should be placed inside [UIPRoot](src/core/README.md#uip-root).
- Script/template tags should have *uip-snippet* attribute and *label* attribute with a snippet's name.
- An active element can be chosen by adding class *active* to script/template, otherwise the first snippet is displayed by default.

**UIPSnippets** component produces [UIPStateModel](src/core/README.md#uip-state-model) changes, but it doesn't observe them.

## Example
UiPSnippetsList observes UIPModel snippets changes and updates the list of available snippets.
Component supports active snippet item marker and snippet selection by click.

## Usage
```html
<uip-snippets-list root="::next"></uip-snippets-list>
<uip-root>
<uip-header>
<uip-snippets></uip-snippets>
</uip-header>
<uip-preview></uip-preview>
...
</uip-root>
<script uip-snippet label='Image Mode: save-ratio'>
<esl-image mode="save-ratio"
data-alt="Alt Text Test"
data-src="img-3-carousel-9-6.jpg"
data-src-base="/images/"></esl-image>
</script>
<script uip-snippet label='Image Mode: cover (additional classes: vertical alignment)'>
<div class="img-container m-auto" style="width: 400px; height: 200px; border: 1px solid gray;">
<esl-image mode="cover"
data-alt="Alt Text"
data-src="img-1-carousel-9-6.jpg | @2x => img-1-carousel-9-6.jpg"
data-src-base="/images/"></esl-image>
</div>
</script>
```
13 changes: 13 additions & 0 deletions src/plugins/snippets-title/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# UIP Snippets Title

**UIPSnippetsTitle** - small plugin to display a title of the currently selected snippet.

# Usage

The following sample will render snippets as a tab list in the header of the UI Playground:
```html
<uip-root>
<uip-snippets-title class="uip-toolbar"></uip-snippets-title>
...
</uip-root>
```
48 changes: 35 additions & 13 deletions src/plugins/snippets/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
# UIP Header
# UIP Snippets

**UIPHeader** - custom element, a container for [UIPSnippets](src/header/snippets/README.md) and [UIPOptions](src/header/options/README.md).
**UIPSnippets** - the primary plugin to display snippets of the UI Playground.

# Description
By default *UIPHeader* initializes *UIPSnippets*, *UIPOptions* and a copy icon inside of it, so you need to add an empty *uip-header* tag only. But you can also manually set what you want it to render. The following example shows
how only [UIPSnippets](src/header/snippets/README.md) can be displayed:
UIPSnippets uses UIPSnippetsList to render the list of snippets and UIPSnippetsTitle to render the title of the list.
UIPSnippets can be rendered in two modes: *list* and *dropdown*.

# Usage

The following sample will render snippets as a tab list in the header of the UI Playground:
```html
<uip-root>
<uip-snippets class="uip-toolbar"></uip-snippets>
...
</uip-root>
```

To render snippets as a dropdown list, use the following snippet:
```html
<uip-root>
<uip-snippets class="uip-toolbar" dropdown-view="all"></uip-snippets>
...
</uip-root>
```

The `dropdown-view` attribute can be any ESLMediaQuery value, so you can switch mode depending on the screen size.
```html
<uip-header>
<uip-snippets></uip-snippets>
</uip-editor>
<uip-root>
<uip-snippets class="uip-toolbar" dropdown-view="(max-width: 768px)"></uip-snippets>
...
</uip-root>
```

An empty *uip-header* is an equivalent to the next snippet:

The class `uip-toolbar` is used to style the section as a toolbar-header for the UI Playground.
The combinations of `uip-snippets` and buttons (e.g. `uip-copy`, `uip-theme-toggle` or `uip-direction-toggle`)
are also allowed with additional div wrapper:
```html
<uip-header>
<uip-snippets></uip-snippets>
<uip-options></uip-options>
<button class="copy-icon" title="copy markup"></button>
<div class="uip-toolbar">
<uip-snippets></uip-snippets>
<uip-theme-toggle></uip-theme-toggle>
</div>
...
</uip-header>
```

0 comments on commit 7c63ba5

Please sign in to comment.