From a3e4827f996fc7fe6cc71a0c85b7128e4624048e Mon Sep 17 00:00:00 2001 From: mcandu Date: Mon, 5 Jul 2021 15:18:59 +0300 Subject: [PATCH] Update SpeedDial & Dock doc --- src/showcase/dock/DockDoc.js | 740 +++++++++++++++++++++++-- src/showcase/speeddial/SpeedDialDoc.js | 206 +++++++ 2 files changed, 910 insertions(+), 36 deletions(-) diff --git a/src/showcase/dock/DockDoc.js b/src/showcase/dock/DockDoc.js index bf26f41a22..264409ee47 100644 --- a/src/showcase/dock/DockDoc.js +++ b/src/showcase/dock/DockDoc.js @@ -326,50 +326,36 @@ export class DockDemo extends Component { ); return ( -
-
- -

Dock

-

Dock is a navigation component consisting of menuitems.

-
- - +
+
Basic
+
+ + + +
-
-
Basic
-
- - - - -
+
Advanced
+ -
Advanced
- + +
+ this.toast = el} /> + this.toast2 = el} position="top-center" /> - -
- this.toast = el} /> - this.toast2 = el} position="top-center" /> + - + this.setState({ displayTerminal: false })} maximizable blockScroll={false}> + + - this.setState({ displayTerminal: false })} maximizable blockScroll={false}> - - - - this.setState({ displayFinder: false })} maximizable blockScroll={false}> - - - - this.galleria = el} value={this.state.images} responsiveOptions={this.responsiveOptions} numVisible={2} style={{ width: '400px' }} - circular fullScreen showThumbnails={false} showItemNavigators item={this.itemTemplate} /> -
+ this.setState({ displayFinder: false })} maximizable blockScroll={false}> + + + this.galleria = el} value={this.state.images} responsiveOptions={this.responsiveOptions} numVisible={2} style={{ width: '400px' }} + circular fullScreen showThumbnails={false} showItemNavigators item={this.itemTemplate} />
- -
) } @@ -379,13 +365,695 @@ export class DockDemo extends Component { 'hooks': { tabName: 'Hooks Source', content: ` +import React, { useState, useEffect } from 'react'; +import PrimeReact from 'primereact/api'; +import { Dock } from 'primereact/dock'; +import { Tooltip } from 'primereact/tooltip'; +import { Dialog } from 'primereact/dialog'; +import { Terminal } from 'primereact/terminal'; +import { TerminalService } from 'primereact/terminalservice'; +import { Galleria } from 'primereact/galleria'; +import { Toast } from 'primereact/toast'; +import { Tree } from 'primereact/tree'; +import { Menubar } from 'primereact/menubar'; +import { NodeService } from '../service/NodeService'; +import { PhotoService } from '../service/PhotoService'; +import './DockDemo.css'; + +export const DockDemo = () => { + + const [displayTerminal, setDisplayTerminal ] = useState(false); + const [displayFinder, setDisplayFinder] = useState(false); + const [images, setImages] = useState(null); + const [nodes, setNodes] = useState(null); + const toast = useRef(null); + const toast2 = useRef(null); + const galleria = useRef(null); + + const nodeService = new NodeService(); + const galleriaService = new PhotoService(); + + const imgPath = 'showcase/demo/images/dock'; + const imgErrorPath = 'https://www.primefaces.org/wp-content/uploads/2020/05/placeholder.png'; + + const dockItems = [ + { + label: 'Finder', + icon: () => Finder e.target.src = imgErrorPath} width="100%" />, + command: () => { + setDisplayFinder(true); + } + }, + { + label: 'Terminal', + icon: () => Finder e.target.src = imgErrorPath} width="100%" />, + command: () => { + setDisplayTerminal(true); + } + }, + { + label: 'App Store', + icon: () => App Store e.target.src = imgErrorPath} width="100%" />, + command: () => { + toast2.current.show({ severity: 'error', summary: 'An unexpected error occurred while signing in.', detail: 'UNTRUSTED_CERT_TITLE' }); + } + }, + { + label: 'Safari', + icon: () => Finder e.target.src = imgErrorPath} width="100%" />, + command: () => { + toast2.current.show({ severity: 'warn', summary: 'Safari has stopped working' }); + } + }, + { + label: 'Photos', + icon: () => Photos e.target.src = imgErrorPath} width="100%" />, + command: () => { + galleria.current.show(); + } + }, + { + label: 'GitHub', + icon: () => Settings e.target.src = imgErrorPath} width="100%" />, + }, + { + label: 'Trash', + icon: () => trash e.target.src = imgErrorPath} width="100%" />, + command: () => { + toast.current.show({ severity: 'info', summary: 'Empty Trash' }); + } + } + ]; + + const dockBasicItems = [ + { + label: 'Finder', + icon: () => Finder e.target.src = imgErrorPath} width="100%" /> + }, + { + label: 'App Store', + icon: () => App Store e.target.src = imgErrorPath} width="100%" /> + }, + { + label: 'Photos', + icon: () => Photos e.target.src = imgErrorPath} width="100%" /> + }, + { + label: 'Trash', + icon: () => trash e.target.src = imgErrorPath} width="100%" /> + } + ]; + + const menubarItems = [ + { + label: 'Finder', + className: 'menubar-root' + }, + { + label: 'File', + items: [ + { + label: 'New', + icon: 'pi pi-fw pi-plus', + items: [ + { + label: 'Bookmark', + icon: 'pi pi-fw pi-bookmark' + }, + { + label: 'Video', + icon: 'pi pi-fw pi-video' + }, + + ] + }, + { + label: 'Delete', + icon: 'pi pi-fw pi-trash' + }, + { + separator: true + }, + { + label: 'Export', + icon: 'pi pi-fw pi-external-link' + } + ] + }, + { + label: 'Edit', + items: [ + { + label: 'Left', + icon: 'pi pi-fw pi-align-left' + }, + { + label: 'Right', + icon: 'pi pi-fw pi-align-right' + }, + { + label: 'Center', + icon: 'pi pi-fw pi-align-center' + }, + { + label: 'Justify', + icon: 'pi pi-fw pi-align-justify' + }, + ] + }, + { + label: 'Users', + items: [ + { + label: 'New', + icon: 'pi pi-fw pi-user-plus', + + }, + { + label: 'Delete', + icon: 'pi pi-fw pi-user-minus', + + }, + { + label: 'Search', + icon: 'pi pi-fw pi-users', + items: [ + { + label: 'Filter', + icon: 'pi pi-fw pi-filter', + items: [ + { + label: 'Print', + icon: 'pi pi-fw pi-print' + } + ] + }, + { + icon: 'pi pi-fw pi-bars', + label: 'List' + } + ] + } + ] + }, + { + label: 'Events', + items: [ + { + label: 'Edit', + icon: 'pi pi-fw pi-pencil', + items: [ + { + label: 'Save', + icon: 'pi pi-fw pi-calendar-plus' + }, + { + label: 'Delete', + icon: 'pi pi-fw pi-calendar-minus' + } + ] + }, + { + label: 'Archieve', + icon: 'pi pi-fw pi-calendar-times', + items: [ + { + label: 'Remove', + icon: 'pi pi-fw pi-calendar-minus' + } + ] + } + ] + }, + { + label: 'Quit' + } + ]; + + const responsiveOptions = [ + { + breakpoint: '1024px', + numVisible: 3 + }, + { + breakpoint: '768px', + numVisible: 2 + }, + { + breakpoint: '560px', + numVisible: 1 + } + ]; + + const itemTemplate = (item) => { + return {item.alt}; + } + + const commandHandler = (text) => { + let response; + let argsIndex = text.indexOf(' '); + let command = argsIndex !== -1 ? text.substring(0, argsIndex) : text; + + switch (command) { + case 'date': + response = 'Today is ' + new Date().toDateString(); + break; + + case 'greet': + response = 'Hola ' + text.substring(argsIndex + 1) + '!'; + break; + + case 'random': + response = Math.floor(Math.random() * 100); + break; + + case 'clear': + response = null; + break; + + default: + response = 'Unknown command: ' + command; + break; + } + + if (response) { + TerminalService.emit('response', response); + } + else { + TerminalService.emit('clear'); + } + } + + useEffect(() => { + TerminalService.on('command', commandHandler); + + galleriaService.getImages().then(data => setImages(data)); + nodeService.getTreeNodes().then(data => setNodes(data)); + + PrimeReact.appendTo = 'self'; + + return () => { + TerminalService.off('command', commandHandler); + + // reset + PrimeReact.appendTo = null; + } + },[]) + + const start = ; + const end = ( + + + + + Fri 13:07 + + + + ); + + return ( +
+
Basic
+
+ + + + +
+ +
Advanced
+ + + +
+ + + + + + setDisplayTerminal(false)} maximizable blockScroll={false}> + + + + setDisplayFinder(false)} maximizable blockScroll={false}> + + + + +
+
+ ) +} ` }, 'ts': { tabName: 'TS Source', content: ` +import React, { useState, useEffect } from 'react'; +import PrimeReact from 'primereact/api'; +import { Dock } from 'primereact/dock'; +import { Tooltip } from 'primereact/tooltip'; +import { Dialog } from 'primereact/dialog'; +import { Terminal } from 'primereact/terminal'; +import { TerminalService } from 'primereact/terminalservice'; +import { Galleria } from 'primereact/galleria'; +import { Toast } from 'primereact/toast'; +import { Tree } from 'primereact/tree'; +import { Menubar } from 'primereact/menubar'; +import { NodeService } from '../service/NodeService'; +import { PhotoService } from '../service/PhotoService'; +import './DockDemo.css'; + +export const DockDemo = () => { + + const [displayTerminal, setDisplayTerminal] = useState(false); + const [displayFinder, setDisplayFinder] = useState(false); + const [images, setImages] = useState(null); + const [nodes, setNodes] = useState(null); + const toast = useRef(null); + const toast2 = useRef(null); + const galleria = useRef(null); + + const nodeService = new NodeService(); + const galleriaService = new PhotoService(); + + const imgPath = 'showcase/demo/images/dock'; + const imgErrorPath = 'https://www.primefaces.org/wp-content/uploads/2020/05/placeholder.png'; + + const dockItems = [ + { + label: 'Finder', + icon: () => Finder e.target.src = imgErrorPath} width="100%" />, + command: () => { + setDisplayFinder(true); + } + }, + { + label: 'Terminal', + icon: () => Finder e.target.src = imgErrorPath} width="100%" />, + command: () => { + setDisplayTerminal(true); + } + }, + { + label: 'App Store', + icon: () => App Store e.target.src = imgErrorPath} width="100%" />, + command: () => { + toast2.current.show({ severity: 'error', summary: 'An unexpected error occurred while signing in.', detail: 'UNTRUSTED_CERT_TITLE' }); + } + }, + { + label: 'Safari', + icon: () => Finder e.target.src = imgErrorPath} width="100%" />, + command: () => { + toast2.current.show({ severity: 'warn', summary: 'Safari has stopped working' }); + } + }, + { + label: 'Photos', + icon: () => Photos e.target.src = imgErrorPath} width="100%" />, + command: () => { + galleria.current.show(); + } + }, + { + label: 'GitHub', + icon: () => Settings e.target.src = imgErrorPath} width="100%" />, + }, + { + label: 'Trash', + icon: () => trash e.target.src = imgErrorPath} width="100%" />, + command: () => { + toast.current.show({ severity: 'info', summary: 'Empty Trash' }); + } + } + ]; + + const dockBasicItems = [ + { + label: 'Finder', + icon: () => Finder e.target.src = imgErrorPath} width="100%" /> + }, + { + label: 'App Store', + icon: () => App Store e.target.src = imgErrorPath} width="100%" /> + }, + { + label: 'Photos', + icon: () => Photos e.target.src = imgErrorPath} width="100%" /> + }, + { + label: 'Trash', + icon: () => trash e.target.src = imgErrorPath} width="100%" /> + } + ]; + const menubarItems = [ + { + label: 'Finder', + className: 'menubar-root' + }, + { + label: 'File', + items: [ + { + label: 'New', + icon: 'pi pi-fw pi-plus', + items: [ + { + label: 'Bookmark', + icon: 'pi pi-fw pi-bookmark' + }, + { + label: 'Video', + icon: 'pi pi-fw pi-video' + }, + + ] + }, + { + label: 'Delete', + icon: 'pi pi-fw pi-trash' + }, + { + separator: true + }, + { + label: 'Export', + icon: 'pi pi-fw pi-external-link' + } + ] + }, + { + label: 'Edit', + items: [ + { + label: 'Left', + icon: 'pi pi-fw pi-align-left' + }, + { + label: 'Right', + icon: 'pi pi-fw pi-align-right' + }, + { + label: 'Center', + icon: 'pi pi-fw pi-align-center' + }, + { + label: 'Justify', + icon: 'pi pi-fw pi-align-justify' + }, + + ] + }, + { + label: 'Users', + items: [ + { + label: 'New', + icon: 'pi pi-fw pi-user-plus', + + }, + { + label: 'Delete', + icon: 'pi pi-fw pi-user-minus', + + }, + { + label: 'Search', + icon: 'pi pi-fw pi-users', + items: [ + { + label: 'Filter', + icon: 'pi pi-fw pi-filter', + items: [ + { + label: 'Print', + icon: 'pi pi-fw pi-print' + } + ] + }, + { + icon: 'pi pi-fw pi-bars', + label: 'List' + } + ] + } + ] + }, + { + label: 'Events', + items: [ + { + label: 'Edit', + icon: 'pi pi-fw pi-pencil', + items: [ + { + label: 'Save', + icon: 'pi pi-fw pi-calendar-plus' + }, + { + label: 'Delete', + icon: 'pi pi-fw pi-calendar-minus' + } + ] + }, + { + label: 'Archieve', + icon: 'pi pi-fw pi-calendar-times', + items: [ + { + label: 'Remove', + icon: 'pi pi-fw pi-calendar-minus' + } + ] + } + ] + }, + { + label: 'Quit' + } + ]; + + const responsiveOptions = [ + { + breakpoint: '1024px', + numVisible: 3 + }, + { + breakpoint: '768px', + numVisible: 2 + }, + { + breakpoint: '560px', + numVisible: 1 + } + ]; + + const itemTemplate = (item) => { + return {item.alt}; + } + + const commandHandler = (text) => { + let response; + let argsIndex = text.indexOf(' '); + let command = argsIndex !== -1 ? text.substring(0, argsIndex) : text; + + switch (command) { + case 'date': + response = 'Today is ' + new Date().toDateString(); + break; + + case 'greet': + response = 'Hola ' + text.substring(argsIndex + 1) + '!'; + break; + + case 'random': + response = Math.floor(Math.random() * 100); + break; + + case 'clear': + response = null; + break; + + default: + response = 'Unknown command: ' + command; + break; + } + + if (response) { + TerminalService.emit('response', response); + } + else { + TerminalService.emit('clear'); + } + } + + useEffect(() => { + TerminalService.on('command', commandHandler); + + galleriaService.getImages().then(data => setImages(data)); + nodeService.getTreeNodes().then(data => setNodes(data)); + + PrimeReact.appendTo = 'self'; + + return () => { + TerminalService.off('command', commandHandler); + + // reset + PrimeReact.appendTo = null; + } + },[]) + + const start = ; + const end = ( + + + + + Fri 13:07 + + + + ); + + return ( +
+
Basic
+
+ + + + +
+ +
Advanced
+ + + +
+ + + + + + setDisplayTerminal(false)} maximizable blockScroll={false}> + + + + setDisplayFinder(false)} maximizable blockScroll={false}> + + + + +
+
+ ) +} ` } } diff --git a/src/showcase/speeddial/SpeedDialDoc.js b/src/showcase/speeddial/SpeedDialDoc.js index f68486ba47..69a9eea78c 100644 --- a/src/showcase/speeddial/SpeedDialDoc.js +++ b/src/showcase/speeddial/SpeedDialDoc.js @@ -126,13 +126,219 @@ export class SpeedDialDemo extends Component { 'hooks': { tabName: 'Hooks Source', content: ` +import React from 'react'; +import { SpeedDial } from 'primereact/speeddial'; +import { Tooltip } from 'primereact/tooltip'; +import { Toast } from 'primereact/toast'; +import './SpeedDialDemo.css' +export const SpeedDialDemo = () => { + + const toast = useRef(null); + + const items = [ + { + label: 'Add', + icon: 'pi pi-pencil', + command: () => { + toast.current.show({ severity: 'info', summary: 'Add', detail: 'Data Added' }); + } + }, + { + label: 'Update', + icon: 'pi pi-refresh', + command: () => { + toast.current.show({ severity: 'success', summary: 'Update', detail: 'Data Updated' }); + } + }, + { + label: 'Delete', + icon: 'pi pi-trash', + command: () => { + toast.current.show({ severity: 'error', summary: 'Delete', detail: 'Data Deleted' }); + } + }, + { + label: 'Upload', + icon: 'pi pi-upload', + command: () => { + window.location.hash = "/fileupload" + } + }, + { + label: 'React Website', + icon: 'pi pi-external-link', + command: () => { + window.location.href = 'https://facebook.github.io/react/' + } + } + ]; + + return ( +
+ + +
+
Linear
+
+ + + + +
+
+ +
+
Circle, Semi-Circle and Quarter-Circle
+
+ + + + + + + + + +
+
+ +
+
Tooltip
+
+ + + + + +
+
+ +
+
Transition Duration, Icon and No Rotate Animation
+
+ +
+
+ +
+
Mask
+
+ +
+
+
+ ) +} ` }, 'ts': { tabName: 'TS Source', content: ` +import React from 'react'; +import { SpeedDial } from 'primereact/speeddial'; +import { Tooltip } from 'primereact/tooltip'; +import { Toast } from 'primereact/toast'; +import './SpeedDialDemo.css' +export const SpeedDialDemo = () => { + + const toast = useRef(null); + + const items = [ + { + label: 'Add', + icon: 'pi pi-pencil', + command: () => { + toast.current.show({ severity: 'info', summary: 'Add', detail: 'Data Added' }); + } + }, + { + label: 'Update', + icon: 'pi pi-refresh', + command: () => { + toast.current.show({ severity: 'success', summary: 'Update', detail: 'Data Updated' }); + } + }, + { + label: 'Delete', + icon: 'pi pi-trash', + command: () => { + toast.current.show({ severity: 'error', summary: 'Delete', detail: 'Data Deleted' }); + } + }, + { + label: 'Upload', + icon: 'pi pi-upload', + command: () => { + window.location.hash = "/fileupload" + } + }, + { + label: 'React Website', + icon: 'pi pi-external-link', + command: () => { + window.location.href = 'https://facebook.github.io/react/' + } + } + ]; + + return ( +
+ + +
+
Linear
+
+ + + + +
+
+ +
+
Circle, Semi-Circle and Quarter-Circle
+
+ + + + + + + + + +
+
+ +
+
Tooltip
+
+ + + + + +
+
+ +
+
Transition Duration, Icon and No Rotate Animation
+
+ +
+
+ +
+
Mask
+
+ +
+
+
+ ) +} ` } }