Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/separator #38

Merged
merged 36 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bd5ae58
init separator
nathan-bird May 2, 2022
1bb3270
docs go away
nathan-bird May 2, 2022
ae374a0
remove color prop
nathan-bird May 2, 2022
ea02dc8
new docs without color prop
nathan-bird May 2, 2022
ef962e6
add tests
nathan-bird May 2, 2022
47ea859
test docs
nathan-bird May 2, 2022
47a6e20
refactor width prop to thickness
nathan-bird May 2, 2022
7d1930b
thickness prop docs
nathan-bird May 2, 2022
be2e00c
flex box to change direction
nathan-bird May 2, 2022
e79dfcd
doc
nathan-bird May 2, 2022
43bee46
added div wrapper to storybook
May 3, 2022
0476017
fixed component tests
May 3, 2022
3990adc
removed unused const in storybook
May 3, 2022
c323302
restored deleted CONSTs removed in error
May 4, 2022
12ccdbb
removed wrapper div. add color prop to be any or inherit
May 5, 2022
1eb9605
tests fixed
May 5, 2022
1881f27
stories updated
May 5, 2022
9409b07
reverted modified file
May 5, 2022
ba485f5
removed inherit as background colors and non-inheritable properties
May 5, 2022
7c150ec
fixed test
May 5, 2022
a65dd0b
defined color prop
May 6, 2022
5c01cec
removed color prop
May 6, 2022
da8828d
Merge branch 'main' into feat/separator
May 6, 2022
6f7b7db
using token as default color prop
May 6, 2022
b2b557e
put example in react app
May 6, 2022
f5e4ef4
fixed test typo
May 6, 2022
0b60a73
refactored component
May 10, 2022
70f70d7
fix(example-react): Fix example react app by providing a single eleme…
TanguyDucky May 11, 2022
c9c5a52
fix(self-close): Expand self-closing tag
TanguyDucky May 11, 2022
ec4040c
Merge branch 'main' into feat/separator
TanguyDucky May 11, 2022
bcb11cb
corrected tests. added all into stories.
May 12, 2022
08e78db
rush build files
May 12, 2022
c6505cf
updated react app. removed self-closing tag
May 12, 2022
6901aa9
removed background color on container div vertical and associated sty…
May 12, 2022
c5209ad
Update packages/component-library/src/components/plmg-separator/plmg-…
jamesducky May 16, 2022
bb62b07
fixed typos
May 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@ducky/plumage-react",
"comment": "",
"type": "none"
}
],
"packageName": "@ducky/plumage-react"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@ducky/plumage-react",
"comment": "",
"type": "none"
}
],
"packageName": "@ducky/plumage-react"
}
10 changes: 10 additions & 0 deletions common/changes/@ducky/plumage/feat-separator_2022-05-02-09-21.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@ducky/plumage",
"comment": "Created separator component and defined first props",
"type": "minor"
}
],
"packageName": "@ducky/plumage"
}
20 changes: 19 additions & 1 deletion examples/react-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
PlmgSidebar,
PlmgSidebarItem,
PlmgSvgIcon,
PlmgSeparator,
nathan-bird marked this conversation as resolved.
Show resolved Hide resolved
} from '@ducky/plumage-react';

ReactDOM.render(
Expand Down Expand Up @@ -39,8 +40,24 @@ ReactDOM.render(
</PlmgSidebarItem>
</PlmgSidebar>
<PlmgHeader slot={'header'}>
<div slot={'right'}>MenuItem</div>
<div
slot={'right'}
style={{
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
}}
>
<span>Menu Item</span>
<PlmgSeparator
thickness="thick"
direction="vertical"
color="#78909C"
></PlmgSeparator>
<span>Menu Item 2</span>
</div>
</PlmgHeader>

<div slot={'content'} style={{ padding: '24px' }}>
<PlmgButton
onClick={(e: any) => {
Expand Down Expand Up @@ -75,6 +92,7 @@ ReactDOM.render(
>
<div slot="slot-1">
<h1>PlmgCard slot-1</h1>
<PlmgSeparator thickness="thick"></PlmgSeparator>
</div>
<div slot="slot-2">
<h1>PlmgCard slot-2</h1>
Expand Down
1 change: 1 addition & 0 deletions packages/component-library-react/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const PlmgButton = /*@__PURE__*/createReactComponent<JSX.PlmgButton, HTML
export const PlmgCard = /*@__PURE__*/createReactComponent<JSX.PlmgCard, HTMLPlmgCardElement>('plmg-card');
export const PlmgHeader = /*@__PURE__*/createReactComponent<JSX.PlmgHeader, HTMLPlmgHeaderElement>('plmg-header');
export const PlmgPageContainer = /*@__PURE__*/createReactComponent<JSX.PlmgPageContainer, HTMLPlmgPageContainerElement>('plmg-page-container');
export const PlmgSeparator = /*@__PURE__*/createReactComponent<JSX.PlmgSeparator, HTMLPlmgSeparatorElement>('plmg-separator');
export const PlmgSidebar = /*@__PURE__*/createReactComponent<JSX.PlmgSidebar, HTMLPlmgSidebarElement>('plmg-sidebar');
export const PlmgSidebarItem = /*@__PURE__*/createReactComponent<JSX.PlmgSidebarItem, HTMLPlmgSidebarItemElement>('plmg-sidebar-item');
export const PlmgSvgIcon = /*@__PURE__*/createReactComponent<JSX.PlmgSvgIcon, HTMLPlmgSvgIconElement>('plmg-svg-icon');
4 changes: 2 additions & 2 deletions packages/component-library/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
};
37 changes: 37 additions & 0 deletions packages/component-library/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ export namespace Components {
*/
"sidebarExpanded": boolean;
}
interface PlmgSeparator {
/**
* Define icon's color. Can be any valid CSS color value. Default is plmgColorBorderNeutral
*/
"color": string;
/**
* Define separator's direction. Allowed values: - vertical - horizontal Default: horizontal
*/
"direction": string;
/**
* Define separator's thickness. Allowed values: - thin - thick Default: thin
*/
"thickness": string;
}
interface PlmgSidebar {
/**
* Invoke this method to collapse the sidebar.
Expand Down Expand Up @@ -187,6 +201,12 @@ declare global {
prototype: HTMLPlmgPageContainerElement;
new (): HTMLPlmgPageContainerElement;
};
interface HTMLPlmgSeparatorElement extends Components.PlmgSeparator, HTMLStencilElement {
}
var HTMLPlmgSeparatorElement: {
prototype: HTMLPlmgSeparatorElement;
new (): HTMLPlmgSeparatorElement;
};
interface HTMLPlmgSidebarElement extends Components.PlmgSidebar, HTMLStencilElement {
}
var HTMLPlmgSidebarElement: {
Expand All @@ -210,6 +230,7 @@ declare global {
"plmg-card": HTMLPlmgCardElement;
"plmg-header": HTMLPlmgHeaderElement;
"plmg-page-container": HTMLPlmgPageContainerElement;
"plmg-separator": HTMLPlmgSeparatorElement;
"plmg-sidebar": HTMLPlmgSidebarElement;
"plmg-sidebar-item": HTMLPlmgSidebarItemElement;
"plmg-svg-icon": HTMLPlmgSvgIconElement;
Expand Down Expand Up @@ -312,6 +333,20 @@ declare namespace LocalJSX {
*/
"sidebarExpanded"?: boolean;
}
interface PlmgSeparator {
/**
* Define icon's color. Can be any valid CSS color value. Default is plmgColorBorderNeutral
*/
"color"?: string;
/**
* Define separator's direction. Allowed values: - vertical - horizontal Default: horizontal
*/
"direction"?: string;
/**
* Define separator's thickness. Allowed values: - thin - thick Default: thin
*/
"thickness"?: string;
}
interface PlmgSidebar {
/**
* Define if the item is expanded on startup.
Expand Down Expand Up @@ -379,6 +414,7 @@ declare namespace LocalJSX {
"plmg-card": PlmgCard;
"plmg-header": PlmgHeader;
"plmg-page-container": PlmgPageContainer;
"plmg-separator": PlmgSeparator;
"plmg-sidebar": PlmgSidebar;
"plmg-sidebar-item": PlmgSidebarItem;
"plmg-svg-icon": PlmgSvgIcon;
Expand All @@ -392,6 +428,7 @@ declare module "@stencil/core" {
"plmg-card": LocalJSX.PlmgCard & JSXBase.HTMLAttributes<HTMLPlmgCardElement>;
"plmg-header": LocalJSX.PlmgHeader & JSXBase.HTMLAttributes<HTMLPlmgHeaderElement>;
"plmg-page-container": LocalJSX.PlmgPageContainer & JSXBase.HTMLAttributes<HTMLPlmgPageContainerElement>;
"plmg-separator": LocalJSX.PlmgSeparator & JSXBase.HTMLAttributes<HTMLPlmgSeparatorElement>;
"plmg-sidebar": LocalJSX.PlmgSidebar & JSXBase.HTMLAttributes<HTMLPlmgSidebarElement>;
"plmg-sidebar-item": LocalJSX.PlmgSidebarItem & JSXBase.HTMLAttributes<HTMLPlmgSidebarItemElement>;
"plmg-svg-icon": LocalJSX.PlmgSvgIcon & JSXBase.HTMLAttributes<HTMLPlmgSvgIconElement>;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@use '~@ducky/plumage-tokens/dist/scss/default' as tokens;

// Common styles to all shadow-DOM components
// -------------------------------------------------
:host {
height: inherit;
width: inherit;
display: block;
}

:host([hidden]) {
display: none;
}
// ------------- END Common styles -----------------

// Component style
// -------------------------------------------------

.plmg-separator-container-vertical {
display: flex;
height: 100%;
}
.plmg-separator-container-horizontal {
display: flex;
width: 100%;
height: 100%;
}

.plmg-separator {
border-radius: tokens.$plmg-border-radius-xl;
border: none;
margin-block-start: 0;
margin-block-end: 0;

&.horizontal {
width: 100%;
&.thin {
height: tokens.$plmg-border-width-s;
}
&.thick {
height: tokens.$plmg-border-width-m;
}
}

&.vertical {
&.thin {
width: tokens.$plmg-border-width-s;
}
&.thick {
width: tokens.$plmg-border-width-m;
}
}
}
// ------------- END Component style ---------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import * as Utils from '../../stories/StencilStorybookUtils';
import { directions, thicknesses } from './plmg-separator.types';

export default {
title: 'Component/Separator',
parameters: {},
decorators: [],
argTypes: {
color: {
control: { type: 'color' },
},
direction: {
control: { type: 'select' },
options: ['horizontal', 'vertical'],
},
thickness: {
control: { type: 'select' },
options: ['thin', 'thick'],
},
},
};

const PROPS = ['color', 'direction', 'thickness'];
const EVENTS = [];
const CSS_VARS = [];

const Template = (args) => {
const el = document.createElement('plmg-separator');
const wrapper = document.createElement('div');
wrapper.style.height = '300px';
wrapper.style.width = '300px';
Utils.bindProps(el, PROPS, args);
Utils.bindEvents(el, EVENTS, args);
Utils.bindStyles(el, CSS_VARS, args);
wrapper.appendChild(el);
return wrapper;
};

export const Primary = Template.bind({});
Primary.storyName = 'Separator';
Primary.args = {
direction: 'horizontal',
thickness: 'thin',
};
jamesducky marked this conversation as resolved.
Show resolved Hide resolved

export const AllThicknesses = (args) => {
const htmlContent = thicknesses
.map(
(thickness) =>
`<div style="width: 300px; height: 300px"><plmg-separator thickness="${thickness}"></plmg separator></div>`
)
.join('')
.trim();

const el = document.createElement('div');
el.innerHTML = htmlContent;
el.style.display = 'flex';
el.style.justifyContent = 'space-between';
el.style['flex-wrap'] = 'wrap';
return el;
};
AllThicknesses.storyName = 'All thicknesses';

export const AllDirections = (args) => {
const htmlContent = directions
.map(
(direction) =>
`<div style="width: 300px; height: 300px;">
<plmg-separator direction="${direction}"></plmg-separator>
</div>
`
)
.join('')
.trim();

const el = document.createElement('div');
el.innerHTML = htmlContent;
el.style.display = 'flex';
el.style.justifyContent = 'space-between';
el.style['flex-wrap'] = 'wrap';
return el;
};
AllDirections.storyName = 'All directions';

export const AllVariations = (args) => {
let htmlContent = '';
directions.forEach((direction) => {
thicknesses.forEach((thickness) => {
htmlContent += `<div style="width: 300px; height: 300px;">
<plmg-separator direction="${direction}" thickness="${thickness}"></plmg-separator>
</div>
`;
});
});

const el = document.createElement('div');
el.innerHTML = htmlContent.trim();
el.style.display = 'flex';
el.style.justifyContent = 'space-between';
el.style['flex-wrap'] = 'wrap';
return el;
};
AllVariations.storyName = 'All variations';
Loading