fix(blocksAntd): remove Timeline and UserAvatar files

This commit is contained in:
Gervwyk 2020-11-24 18:35:51 +02:00
parent c2e9dac21d
commit 7300e49ad9
10 changed files with 0 additions and 491 deletions

View File

@ -1,8 +0,0 @@
- id: default
type: Timeline
- id: properties.items
type: Timeline
properties:
items:
- title: one
- title: two

View File

@ -1,6 +0,0 @@
- id: default
type: UserAvatar
- id: properties.name
type: UserAvatar
properties:
name: Avatar name

View File

@ -1,75 +0,0 @@
/*
Copyright 2020 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React from 'react';
import { Timeline } from 'antd';
import { blockDefaultProps } from '@lowdefy/block-tools';
import { get, mergeObjects, serializer, type } from '@lowdefy/helpers';
import Icon from '../Icon/Icon';
const TimelineBlock = ({ blockId, list, methods, properties }) => {
const other = {};
if (properties.mode) {
other.mode = properties.mode;
}
return (
<Timeline
id={blockId}
className={methods.makeCssClass([{ padding: '5px 0px 0px 5px' }, properties.style])}
pending={properties.pending}
pendingDot={
properties.pendingDotIcon && (
<Icon
methods={methods}
properties={mergeObjects([{ style: { fontSize: 16 } }, properties.pendingDotIcon])}
/>
)
}
reverse={properties.reverse}
{...other}
>
{(list || []).map((child, i) => {
let icon = serializer.copy(get(properties, `data.${i}.${properties.iconField || 'icon'}`));
let styleDot = get(properties, `data.${i}.${properties.iconField || 'style'}`);
if (type.isString(icon)) {
icon = { name: icon };
}
if (!type.isObject(styleDot)) {
styleDot = {};
}
return (
<Timeline.Item
key={`${blockId}_${i}`}
color={get(properties, `data.${i}.${properties.colorField || 'color'}`)}
position={get(properties, `data.${i}.${properties.positionField || 'position'}`)}
dot={
icon && (
<Icon methods={methods} properties={mergeObjects([icon, { style: styleDot }])} />
)
}
>
{child.content && child.content()}
</Timeline.Item>
);
})}
</Timeline>
);
};
TimelineBlock.defaultProps = blockDefaultProps;
export default TimelineBlock;

View File

@ -1,59 +0,0 @@
{
"category": "list",
"loading": false,
"schema": {
"properties": {
"type": "object",
"additionalProperties": false,
"properties": {
"style": {
"type": "object",
"description": "Css style object to apply to timeline."
},
"pendingDotIcon": {
"type": ["object", "string"],
"description": "Set the dot of the last ghost node when pending is true."
},
"pending": {
"type": "boolean",
"description": "Set the last ghost node's existence or its content."
},
"reverse": {
"type": "boolean",
"description": "Reverse timeline nodes."
},
"mode": {
"type": "string",
"enum": ["left", "right", "alternate"],
"description": "By sending alternate the timeline will distribute the nodes to the left and right."
},
"data": {
"type": "array",
"description": "Timeline items.",
"items": {
"type": "object",
"properties": {
"color": {
"type": "string",
"description": "Customize dot color."
},
"position": {
"type": "string",
"enum": ["left", "right"],
"description": "Customize node position."
},
"label": {
"type": "string",
"description": "Set the label."
},
"iconField": {
"type": ["string", "object"],
"description": "Name of an Ant Design Icon or properties of an Icon block to customize the item timeline icon."
}
}
}
}
}
}
}
}

View File

@ -1,114 +0,0 @@
/*
Copyright 2020 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React, { useEffect } from 'react';
import { mergeObjects } from '@lowdefy/helpers';
import { blockDefaultProps } from '@lowdefy/block-tools';
import Avatar from '../Avatar/Avatar';
import Button from '../Button/Button';
const UserAvatar = ({ blockId, methods, properties, user }) => {
useEffect(() => {
methods.registerAction('onBlockLogin', [
{
id: 'login',
type: 'Login',
},
]);
methods.registerAction('onBlockAvatar', [
{
id: 'profileClick',
type: 'Link',
params: { pageId: 'profile' },
},
]);
}, []);
if (properties.disabled) {
return '';
}
if (!user.name || properties.loggedIn === false) {
return (
<Button
blockId={`${blockId}_Login`}
properties={mergeObjects([
{
title: 'Login',
type: 'primary',
shape: 'round',
icon: { name: 'LoginOutlined' },
style: { margin: 8 },
},
properties.loginButton,
])}
methods={methods}
onClick={async () => {
await methods.callAction({ action: 'onLogin', hideLoading: true });
methods.callAction({ action: 'onBlockLogin', hideLoading: true });
}}
/>
);
}
return (
<div
id={blockId}
className={methods.makeCssClass([
{
alignItems: 'center',
cursor: 'pointer',
display: 'flex',
outline: 'none',
},
properties.style,
])}
onClick={async () => {
await methods.callAction({ action: 'onClick', hideLoading: true });
methods.callAction({ action: 'onBlockAvatar', hideLoading: true });
}}
>
<div
className={methods.makeCssClass({
color: properties.theme !== 'light' && 'white',
margin: 8,
flex: '0 1 auto',
lineHeight: 1.5,
})}
>
{properties.name || user.name}
</div>
<Avatar
blockId={`${blockId}_Avatar`}
properties={mergeObjects([
{
size: 'large',
src: user.picture,
style: {
margin: 8,
flex: '0 1 auto',
order: properties.showName === 'right' ? -1 : 0,
},
},
properties.avatar,
])}
methods={methods}
/>
</div>
);
};
UserAvatar.defaultProps = blockDefaultProps;
export default UserAvatar;

View File

@ -1,59 +0,0 @@
{
"category": "display",
"loading": false,
"schema": {
"properties": {
"type": "object",
"additionalProperties": false,
"properties": {
"disabled": {
"type": "boolean",
"default": false,
"description": "Do not render the user menu"
},
"showName": {
"type": "string",
"enum": ["left", "right", "none"],
"description": "Where to position the user name"
},
"name": {
"type": "string",
"description": "Replace name text"
},
"theme": {
"type": "string",
"default": "dark",
"enum": ["light", "dark"],
"description": "Color theme"
},
"loggedIn": {
"type": "boolean",
"default": true,
"description": "Render as logged in"
},
"avatar": {
"type": "object",
"description": "User avatar options"
},
"loginButton": {
"type": "object",
"description": "Login button options"
}
}
},
"actions": {
"type": "object",
"additionalProperties": false,
"properties": {
"onClick": {
"type": "array",
"description": "Action on avatar click"
},
"onLogin": {
"type": "array",
"description": "Action on login button click"
}
}
}
}
}

View File

@ -1,24 +0,0 @@
/*
Copyright 2020 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { runBlockSchemaTests, runRenderTests } from '@lowdefy/block-tools';
import Timeline from '../src/blocks/Timeline/Timeline';
import examples from '../demo/examples/Timeline.yaml';
import meta from '../src/blocks/Timeline/Timeline.json';
runRenderTests({ examples, Block: Timeline, meta });
runBlockSchemaTests({ examples, meta });

View File

@ -1,24 +0,0 @@
/*
Copyright 2020 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { runBlockSchemaTests, runRenderTests } from '@lowdefy/block-tools';
import UserAvatar from '../src/blocks/UserAvatar/UserAvatar';
import examples from '../demo/examples/UserAvatar.yaml';
import meta from '../src/blocks/UserAvatar/UserAvatar.json';
runRenderTests({ examples, Block: UserAvatar, meta });
runBlockSchemaTests({ examples, meta });

View File

@ -1,35 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Render default 1`] = `
<ul
className="ant-timeline {\\"style\\":[{\\"padding\\":\\"5px 0px 0px 5px\\"},null]}"
id="default"
/>
`;
exports[`Render properties.items 1`] = `
<ul
className="ant-timeline {\\"style\\":[{\\"padding\\":\\"5px 0px 0px 5px\\"},null]}"
id="properties.items"
/>
`;
exports[`Test Schema default 1`] = `true`;
exports[`Test Schema default 2`] = `null`;
exports[`Test Schema properties.items 1`] = `false`;
exports[`Test Schema properties.items 2`] = `
Array [
Object {
"dataPath": "/properties",
"keyword": "additionalProperties",
"message": "should NOT have additional properties",
"params": Object {
"additionalProperty": "items",
},
"schemaPath": "#/properties/properties/additionalProperties",
},
]
`;

View File

@ -1,87 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Render default 1`] = `
<button
className="ant-btn {\\"style\\":[{},{\\"margin\\":8}]} ant-btn-primary ant-btn-round"
id="default_Login"
onClick={[Function]}
type="button"
>
<span
aria-label="loading-3-quarters"
className="anticon anticon-loading-3-quarters {}"
content={Object {}}
id="undefined_id"
list={Array []}
menus={Array []}
role="img"
user={Object {}}
validate={Array []}
>
<svg
aria-hidden="true"
className="anticon-spin"
data-icon="loading-3-quarters"
fill="currentColor"
focusable="false"
height="1em"
viewBox="0 0 1024 1024"
width="1em"
>
<path
d="M512 1024c-69.1 0-136.2-13.5-199.3-40.2C251.7 958 197 921 150 874c-47-47-84-101.7-109.8-162.7C13.5 648.2 0 581.1 0 512c0-19.9 16.1-36 36-36s36 16.1 36 36c0 59.4 11.6 117 34.6 171.3 22.2 52.4 53.9 99.5 94.3 139.9 40.4 40.4 87.5 72.2 139.9 94.3C395 940.4 452.6 952 512 952c59.4 0 117-11.6 171.3-34.6 52.4-22.2 99.5-53.9 139.9-94.3 40.4-40.4 72.2-87.5 94.3-139.9C940.4 629 952 571.4 952 512c0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.2C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3s-13.5 136.2-40.2 199.3C958 772.3 921 827 874 874c-47 47-101.8 83.9-162.7 109.7-63.1 26.8-130.2 40.3-199.3 40.3z"
/>
</svg>
</span>
<span>
Login
</span>
</button>
`;
exports[`Render properties.name 1`] = `
<button
className="ant-btn {\\"style\\":[{},{\\"margin\\":8}]} ant-btn-primary ant-btn-round"
id="properties.name_Login"
onClick={[Function]}
type="button"
>
<span
aria-label="loading-3-quarters"
className="anticon anticon-loading-3-quarters {}"
content={Object {}}
id="undefined_id"
list={Array []}
menus={Array []}
role="img"
user={Object {}}
validate={Array []}
>
<svg
aria-hidden="true"
className="anticon-spin"
data-icon="loading-3-quarters"
fill="currentColor"
focusable="false"
height="1em"
viewBox="0 0 1024 1024"
width="1em"
>
<path
d="M512 1024c-69.1 0-136.2-13.5-199.3-40.2C251.7 958 197 921 150 874c-47-47-84-101.7-109.8-162.7C13.5 648.2 0 581.1 0 512c0-19.9 16.1-36 36-36s36 16.1 36 36c0 59.4 11.6 117 34.6 171.3 22.2 52.4 53.9 99.5 94.3 139.9 40.4 40.4 87.5 72.2 139.9 94.3C395 940.4 452.6 952 512 952c59.4 0 117-11.6 171.3-34.6 52.4-22.2 99.5-53.9 139.9-94.3 40.4-40.4 72.2-87.5 94.3-139.9C940.4 629 952 571.4 952 512c0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.2C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3s-13.5 136.2-40.2 199.3C958 772.3 921 827 874 874c-47 47-101.8 83.9-162.7 109.7-63.1 26.8-130.2 40.3-199.3 40.3z"
/>
</svg>
</span>
<span>
Login
</span>
</button>
`;
exports[`Test Schema default 1`] = `true`;
exports[`Test Schema default 2`] = `null`;
exports[`Test Schema properties.name 1`] = `true`;
exports[`Test Schema properties.name 2`] = `null`;