Skip to content

Commit d9af0cf

Browse files
author
ci-bot
committed
setup and state changes for template explorer modal
1 parent d51456a commit d9af0cf

File tree

7 files changed

+54
-5
lines changed

7 files changed

+54
-5
lines changed

apps/remix-ide/src/app/plugins/notification.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class NotificationPlugin extends Plugin implements MethodApi<INotificatio
3838
}
3939

4040
async templateExplorer(args: TemplateExplorerModal) {
41+
console.log('templateExplorer', args)
4142
return this.dispatcher.templateExplorer(args)
4243
}
4344

libs/remix-ui/app/src/lib/remix-app/components/modals/dialogViewPlugin.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { AppContext } from '../../context/context'
33
import { useDialogDispatchers } from '../../context/provider'
44

55
const DialogViewPlugin = () => {
6-
const { modal, alert, toast } = useDialogDispatchers()
6+
const { modal, alert, toast, templateExplorer } = useDialogDispatchers()
77
const app = useContext(AppContext)
88

99
useEffect(() => {
10-
app.modal.setDispatcher({ modal, alert, toast })
10+
app.modal.setDispatcher({ modal, alert, toast, templateExplorer })
1111
}, [])
1212
return <></>
1313
}

libs/remix-ui/app/src/lib/remix-app/context/provider.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ declare global {
1414
}
1515

1616
export const ModalProvider = ({ children = [], reducer = modalReducer, initialState = ModalInitialState } = {}) => {
17-
const [{ modals, toasters, focusModal, focusToaster }, dispatch] = useReducer(reducer, initialState)
17+
const [{ modals, toasters, focusModal, focusToaster, focusTemplateExplorer }, dispatch] = useReducer(reducer, initialState)
1818

1919
const onNextFn = async () => {
2020
dispatch({
@@ -118,7 +118,7 @@ export const ModalProvider = ({ children = [], reducer = modalReducer, initialSt
118118

119119
return (
120120
<dispatchModalContext.Provider value={{ modal, toast, alert, handleHideModal, handleToaster, templateExplorer }}>
121-
<modalContext.Provider value={{ modals, toasters, focusModal, focusToaster }}>{children}</modalContext.Provider>
121+
<modalContext.Provider value={{ modals, toasters, focusModal, focusToaster, focusTemplateExplorer }}>{children}</modalContext.Provider>
122122
</dispatchModalContext.Provider>
123123
)
124124
}
@@ -141,3 +141,11 @@ export const useDialogs = () => {
141141
export const useDialogDispatchers = () => {
142142
return React.useContext(dispatchModalContext)
143143
}
144+
145+
export function defaultFocusTemplateExplorer () {
146+
return (
147+
<>
148+
<p className="fs-3 text-center">Template Explorer</p>
149+
</>
150+
)
151+
}

libs/remix-ui/app/src/lib/remix-app/interface/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface ModalState {
4343
toasters: {message: (string | JSX.Element), timestamp: number }[],
4444
focusModal: AppModal,
4545
focusToaster: {message: (string | JSX.Element), timestamp: number }
46+
focusTemplateExplorer: TemplateExplorerModal
4647
}
4748

4849
export interface forceChoiceModal {

libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,9 @@ export const modalReducer = (state: ModalState = ModalInitialState, action: Moda
8383
return { ...state, toasters: []}
8484
}
8585
}
86+
87+
case modalActionTypes.setTemplateExplorer: {
88+
return { ...state, focusTemplateExplorer: action.payload }
89+
}
8690
}
8791
}

libs/remix-ui/app/src/lib/remix-app/state/modals.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { Template, TemplateGroup } from '@remix-ui/workspace'
12
import { ModalState } from '../interface'
3+
import { defaultFocusTemplateExplorer } from '../context/provider'
24

35
export const ModalInitialState: ModalState = {
46
modals: [],
@@ -15,5 +17,25 @@ export const ModalInitialState: ModalState = {
1517
cancelFn: () => { },
1618
showCancelIcon: false
1719
},
18-
focusToaster: { message: '', timestamp: 0 }
20+
focusToaster: { message: '', timestamp: 0 },
21+
focusTemplateExplorer: {
22+
id: '',
23+
hide: true,
24+
title: '',
25+
message: defaultFocusTemplateExplorer(),
26+
validationFn: () => { return { valid: true, message: '' } },
27+
okLabel: '',
28+
okFn: () => { },
29+
cancelLabel: '',
30+
cancelFn: () => { },
31+
showCancelIcon: false,
32+
preventBlur: false,
33+
placeholderText: '',
34+
workspaceName: '',
35+
modifyWorkspaceName: false,
36+
workspaceDescription: '',
37+
workspaceTemplateOptions: {},
38+
workspaceTemplateGroup: {} as TemplateGroup,
39+
workspaceTemplate: {} as Template,
40+
}
1941
}

libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
7777
// return (<></>)
7878
// }
7979

80+
const openTemplateExplorer = async () => {
81+
console.log('openTemplateExplorer')
82+
await plugin.call('notification', 'templateExplorer', {
83+
id: 'templateExplorer',
84+
title: 'Explore all templates',
85+
message: <div>Explore all templates</div>,
86+
okLabel: 'Explore all templates',
87+
okFn: () => {}
88+
})
89+
_paq.push(['trackEvent', 'hometab', 'header', 'Explore all templates'])
90+
}
91+
8092
return (
8193
<div className="d-flex flex-column w-100" data-id="remixUIHTAll">
8294
<ThemeContext.Provider value={state.themeQuality}>
@@ -85,6 +97,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
8597
<div className="d-flex w-100 m-3 justify-content-end">
8698
<button className="btn btn-secondary btn-md me-3" onClick={startLearnEth}><i className="fa-solid fa-book me-1"></i><FormattedMessage id="home.startLearning" /></button>
8799
<button data-id="landingPageImportFromTemplate" className="btn btn-primary btn-md me-2" onClick={openTemplateSelection}><i className="fa-solid fa-plus me-1"></i><FormattedMessage id="home.createNewWorkspace" /></button>
100+
<button className="btn btn-secondary btn-md me-3" onClick={openTemplateExplorer}><i className="fa-solid fa-book me-1"></i>Open Template Explorer</button>
88101
</div>
89102
<div className="col-lg-8 col-xl-5 col-sm-12 mb-4">
90103
<HomeTabTitle />

0 commit comments

Comments
 (0)