Skip to content

Commit 609b0d0

Browse files
authored
Merge pull request #708 from Lemoncode/dev
loading indicator
2 parents 52e2151 + 50f1378 commit 609b0d0

File tree

13 files changed

+161
-3
lines changed

13 files changed

+161
-3
lines changed

public/assets/iria-carballo.jpeg

67.1 KB
Loading
Lines changed: 10 additions & 0 deletions
Loading

src/common/components/mock-components/front-rich-components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export * from './appBar';
1414
export * from './buttonBar/buttonBar';
1515
export * from './tabsbar';
1616
export * from './audio-player';
17+
export * from './loading-indicator';
1718
export * from './videoconference';
1819
export * from './togglelightdark-shape';
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { useRef, forwardRef } from 'react';
2+
import { Group, Rect, Text, Circle } from 'react-konva';
3+
import Konva from 'konva';
4+
import { ShapeProps } from '../shape.model';
5+
import { ShapeSizeRestrictions, ShapeType } from '@/core/model';
6+
import { BASIC_SHAPE } from '../front-components/shape.const';
7+
import { useShapeProps } from '../../shapes/use-shape-props.hook';
8+
import { useGroupShapeProps } from '../mock-components.utils';
9+
10+
const LoadIndicatorSizeRestrictions: ShapeSizeRestrictions = {
11+
minWidth: 200,
12+
minHeight: 100,
13+
maxWidth: -1,
14+
maxHeight: -1,
15+
defaultWidth: 200,
16+
defaultHeight: 100,
17+
};
18+
19+
const shapeType: ShapeType = 'loading-indicator';
20+
21+
export const getLoadIndicatorSizeRestrictions = (): ShapeSizeRestrictions =>
22+
LoadIndicatorSizeRestrictions;
23+
24+
export const LoadIndicator = forwardRef<any, ShapeProps>((props, ref) => {
25+
const { x, y, width, height, otherProps, ...shapeProps } = props;
26+
27+
const restrictedSize = {
28+
width: width || LoadIndicatorSizeRestrictions.defaultWidth,
29+
height: height || LoadIndicatorSizeRestrictions.defaultHeight,
30+
};
31+
32+
const { width: restrictedWidth, height: restrictedHeight } = restrictedSize;
33+
34+
const colors = ['#666', '#888', '#aaa', '#ccc'];
35+
const circlesRef = useRef<Array<Konva.Circle | null>>([]);
36+
37+
const { textColor } = useShapeProps(otherProps, BASIC_SHAPE);
38+
39+
const commonGroupProps = useGroupShapeProps(
40+
props,
41+
restrictedSize,
42+
shapeType,
43+
ref
44+
);
45+
46+
const circleRadius = Math.min(restrictedWidth / 10, 15);
47+
const circleSpacing = restrictedWidth / (colors.length + 1);
48+
49+
return (
50+
<Group {...commonGroupProps} {...shapeProps} draggable>
51+
{/* Load Indicator Background */}
52+
<Rect
53+
x={0}
54+
y={0}
55+
width={restrictedWidth}
56+
height={restrictedHeight}
57+
strokeWidth={BASIC_SHAPE.DEFAULT_STROKE_WIDTH}
58+
/>
59+
60+
{/* Animated Circles */}
61+
{colors.map((color, index) => (
62+
<Circle
63+
key={index}
64+
ref={el => (circlesRef.current[index] = el)}
65+
x={circleSpacing * (index + 1)}
66+
y={restrictedHeight / 2}
67+
radius={circleRadius}
68+
fill={color}
69+
stroke="#000"
70+
strokeWidth={2}
71+
/>
72+
))}
73+
74+
{/* Loading Text */}
75+
<Text
76+
x={0}
77+
y={restrictedHeight - 25}
78+
width={restrictedWidth}
79+
text={props.text || 'Loading...'}
80+
fontFamily={BASIC_SHAPE.DEFAULT_FONT_FAMILY}
81+
fontSize={BASIC_SHAPE.DEFAULT_FONT_SIZE}
82+
fill={textColor}
83+
align="center"
84+
ellipsis={true}
85+
wrap="none"
86+
/>
87+
</Group>
88+
);
89+
});
90+
91+
export default LoadIndicator;

src/core/model/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export type ShapeType =
7171
| 'slider'
7272
| 'link'
7373
| 'cilinder'
74+
| 'richtext'
75+
| 'loading-indicator'
7476
| 'videoconference'
7577
| 'richtext';
7678

@@ -134,6 +136,7 @@ export const ShapeDisplayName: Record<ShapeType, string> = {
134136
slider: 'Slider',
135137
richtext: 'Rich Text',
136138
cilinder: 'Cilinder',
139+
'loading-indicator': 'Loading',
137140
videoconference: 'Videoconference',
138141
};
139142

src/pods/about/members.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,23 @@ export const memberList: Member[] = [
136136
urlLinkedin: 'https://www.linkedin.com/in/sergioelmoreno/',
137137
image: './assets/sergio-del-campo.jpg',
138138
},
139-
140139
{
141140
id: '18',
141+
name: 'Iria',
142+
surname: 'Carballo',
143+
urlLinkedin: 'https://www.linkedin.com/in/iria-carballo/',
144+
image: './assets/iria-carballo.jpeg',
145+
},
146+
{
147+
id: '19',
142148
name: 'Gabriel',
143149
surname: 'Ionut',
144150
urlLinkedin: 'https://www.linkedin.com/in/gabriel-ionut-birsan-b14816307/',
145151
image: './assets/gabriel-ionut.jpeg',
146152
},
147153

148154
{
149-
id: '19',
155+
id: '20',
150156
name: 'Antonio',
151157
surname: 'Contreras',
152158
urlLinkedin:
@@ -155,7 +161,7 @@ export const memberList: Member[] = [
155161
},
156162

157163
{
158-
id: '20',
164+
id: '21',
159165
name: 'Braulio',
160166
surname: 'Diez',
161167
urlLinkedin: 'https://www.linkedin.com/in/brauliodiez/',

src/pods/canvas/model/inline-editable.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const inlineEditableShapes = new Set<ShapeType>([
3636
'datepickerinput',
3737
'browser',
3838
'modalDialog',
39+
'loading-indicator',
3940
]);
4041

4142
// Check if a shape type allows inline editing
@@ -76,6 +77,7 @@ const shapeTypesWithDefaultText = new Set<ShapeType>([
7677
'datepickerinput',
7778
'browser',
7879
'modalDialog',
80+
'loading-indicator',
7981
]);
8082

8183
// Map of ShapeTypes to their default text values
@@ -113,6 +115,7 @@ const defaultTextValueMap: Partial<Record<ShapeType, string>> = {
113115
datepickerinput: new Date().toLocaleDateString(),
114116
browser: 'https://example.com',
115117
modalDialog: 'Title here...',
118+
'loading-indicator': 'Loading...',
116119
};
117120

118121
export const generateDefaultTextValue = (

src/pods/canvas/model/shape-size.mapper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252
getCalendarShapeSizeRestrictions,
5353
getHorizontalMenuShapeSizeRestrictions,
5454
getLineChartShapeSizeRestrictions,
55+
getLoadIndicatorSizeRestrictions,
5556
getMapChartShapeSizeRestrictions,
5657
getModalShapeSizeRestrictions,
5758
getPieChartShapeSizeRestrictions,
@@ -145,6 +146,7 @@ const shapeSizeMap: Record<ShapeType, () => ShapeSizeRestrictions> = {
145146
slider: getSliderShapeSizeRestrictions,
146147
audioPlayer: getAudioPlayerShapeSizeRestrictions,
147148
cilinder: getCilinderShapeSizeRestrictions,
149+
'loading-indicator': getLoadIndicatorSizeRestrictions,
148150
videoconference: getVideoconferenceShapeSizeRestrictions,
149151
};
150152

src/pods/canvas/model/transformer.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const generateTypeOfTransformer = (shapeType: ShapeType): string[] => {
6464
case 'link':
6565
case 'horizontalScrollBar':
6666
case 'appBar':
67+
case 'loading-indicator':
6768
case 'buttonBar':
6869
case 'slider':
6970
return ['middle-left', 'middle-right'];

src/pods/canvas/shape-renderer/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import { renderSmalltext } from './simple-text-components/smalltext.renderer';
7070
import { renderImage } from './simple-basic-shapes/image.renderer';
7171
import { renderCalendar } from './simple-rich-components/calendar.renderer';
7272
import { renderAppBar } from './simple-rich-components/appBar.renderer';
73+
import { renderLoadingIndicator } from './simple-rich-components/loading-indicator.renderer';
7374

7475
export const renderShapeComponent = (
7576
shape: ShapeModel,
@@ -192,6 +193,8 @@ export const renderShapeComponent = (
192193
return renderSlider(shape, shapeRenderedProps);
193194
case 'cilinder':
194195
return renderCilinder(shape, shapeRenderedProps);
196+
case 'loading-indicator':
197+
return renderLoadingIndicator(shape, shapeRenderedProps);
195198
case 'videoconference':
196199
return renderVideoconference(shape, shapeRenderedProps);
197200
default:

0 commit comments

Comments
 (0)