Skip to content

Commit e475c0b

Browse files
author
ci-bot
committed
light up topcards. add behaviour to facade
1 parent b976769 commit e475c0b

File tree

18 files changed

+198
-155
lines changed

18 files changed

+198
-155
lines changed

apps/remix-ide/src/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class AppComponent {
535535

536536
const bottomBarPanel = new BottomBarPanel()
537537

538-
this.engine.register([this.menuicons, landingPage, this.hiddenPanel, this.sidePanel, this.statusBar, this.topBar, filePanel, pluginManagerComponent, this.settings, this.pinnedPanel, this.popupPanel, bottomBarPanel])
538+
this.engine.register([this.menuicons, landingPage, this.hiddenPanel, this.sidePanel, this.statusBar, filePanel, pluginManagerComponent, this.settings, this.pinnedPanel, this.popupPanel, bottomBarPanel])
539539

540540
// CONTENT VIEWS & DEFAULT PLUGINS
541541
const openZeppelinProxy = new OpenZeppelinProxy(blockchain)
@@ -577,7 +577,7 @@ class AppComponent {
577577
openZeppelinProxy,
578578
run.recorder
579579
])
580-
this.engine.register([templateExplorerModal])
580+
this.engine.register([templateExplorerModal, this.topBar])
581581

582582
this.layout.panels = {
583583
tabs: { plugin: tabProxy, active: true },
@@ -616,7 +616,7 @@ class AppComponent {
616616
])
617617

618618
await this.appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs'])
619-
await this.appManager.activatePlugin(['topbar'])
619+
await this.appManager.activatePlugin(['topbar', 'templateexplorermodal'])
620620
await this.appManager.activatePlugin(['statusBar'])
621621
// await this.appManager.activatePlugin(['remix-template-explorer-modal'])
622622
await this.appManager.activatePlugin(['bottomBar'])

apps/remix-ide/src/app/plugins/remix-template-explorer-modal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export class TemplateExplorerModalPlugin extends ViewPlugin {
3939
}
4040

4141
async onActivation(): Promise<void> {
42-
console.trace()
4342
this.on('theme', 'themeChanged', (theme: any) => {
4443
this.theme = theme
4544
})

apps/remix-ide/src/app/plugins/remix-templates.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ export class TemplatesPlugin extends Plugin {
2727
const files = await templateWithContent[template](opts, this)
2828
return files
2929
}
30+
31+
async getTemplateReadMeFile(templateName: string) {
32+
const files = await templateWithContent[templateName]({}, this)
33+
const readMe = files['README.md'] || files['README.txt']
34+
return readMe
35+
}
3036
// electron only method
3137

3238
async addToCurrentElectronFolder(template: string, opts?: any) {

libs/remix-ui/template-explorer-modal/context/template-explorer-context.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const TemplateExplorerProvider = (props: { plugin: TemplateExplorerModalP
1515
const [state, dispatch] = useReducer(templateExplorerReducer, initialState)
1616
const appContext = useContext(AppContext)
1717
const { plugin } = props
18-
const makeWorkspace = new TemplateExplorerModalFacade(plugin)
18+
const facade = new TemplateExplorerModalFacade(plugin)
1919
const templateCategoryStrategy = new TemplateCategoryStrategy()
2020

2121
useEffect(() => {
@@ -159,7 +159,7 @@ export const TemplateExplorerProvider = (props: { plugin: TemplateExplorerModalP
159159
}
160160
}
161161

162-
const contextValue = { templateRepository: state.templateRepository, metadata: state.metadata, selectedTag: state.selectedTag, recentTemplates, filteredTemplates, dedupedTemplates, handleTagClick, clearFilter, addRecentTemplate, RECENT_KEY, allTags, plugin, setSearchTerm, dispatch, state, theme: plugin.theme, makeWorkspace, templateCategoryStrategy }
162+
const contextValue = { templateRepository: state.templateRepository, metadata: state.metadata, selectedTag: state.selectedTag, recentTemplates, filteredTemplates, dedupedTemplates, handleTagClick, clearFilter, addRecentTemplate, RECENT_KEY, allTags, plugin, setSearchTerm, dispatch, state, theme: plugin.theme, facade, templateCategoryStrategy }
163163

164164
return (
165165
<TemplateExplorerContext.Provider value={contextValue}>

libs/remix-ui/template-explorer-modal/src/components/contract-wizard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const defaultStrategy: ContractTypeStrategy = {
2929

3030
export function ContractWizard () {
3131
const [showEditModal, setShowEditModal] = useState(false)
32-
const { state, dispatch, theme, makeWorkspace } = useContext(TemplateExplorerContext)
32+
const { state, dispatch, theme, facade } = useContext(TemplateExplorerContext)
3333
const strategy = state
3434

3535
function toggleContractOption(key: keyof typeof strategy.contractOptions) {
@@ -70,7 +70,7 @@ export function ContractWizard () {
7070
<div className="row g-3">
7171
<div className="col-12 d-flex align-items-center justify-content-between">
7272
<div className="d-flex align-items-center gap-2">
73-
{showEditModal ? <input className="form-control form-control-sm" value={state.tokenName} onChange={(e) => updateContractName(e.target.value)} /> : <span className={`fw-semibold fs-6 ${theme.currentTheme().name === 'Light' ? 'text-dark' : 'text-light'}`}>
73+
{showEditModal ? <input className="form-control form-control-sm" value={state.tokenName} onChange={(e) => updateContractName(e.target.value)} /> : <span className={`fw-semibold fs-6 ${theme.currentTheme().name === 'Light' ? 'text-dark' : 'text-white'}`}>
7474
{state.tokenName}
7575
</span>}
7676
<i className="fas fa-edit" onClick={() => setShowEditModal(true)}></i>
@@ -165,7 +165,7 @@ export function ContractWizard () {
165165

166166
<button className="btn btn-primary btn-sm" data-id="validateWorkspaceButton" onClick={async () => {
167167
console.log('about to create workspace')
168-
await makeWorkspace.createWorkspace({
168+
await facade.createWorkspace({
169169
workspaceName: state.workspaceTemplateChosen.displayName,
170170
workspaceTemplateName: state.workspaceTemplateChosen.value,
171171
opts: { mintable: state.contractOptions.mintable, burnable: state.contractOptions.burnable, pausable: state.contractOptions.pausable, uups: state.contractUpgradability.uups, transparent: state.contractUpgradability.transparent },

libs/remix-ui/template-explorer-modal/src/components/genericWorkspaceTemplate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { TemplateExplorerContext } from '../../context/template-explorer-context
55

66
export function GenericWorkspaceTemplate() {
77

8-
const { state, dispatch, makeWorkspace } = useContext(TemplateExplorerContext)
8+
const { state, dispatch, facade } = useContext(TemplateExplorerContext)
99

1010
return (
1111
<section className="mx-3 p-2">
@@ -28,7 +28,7 @@ export function GenericWorkspaceTemplate() {
2828

2929
<button className="btn btn-primary btn-sm" data-id="validateWorkspaceButton" onClick={async () => {
3030
console.log('about to create workspace generic')
31-
await makeWorkspace.createWorkspace({
31+
await facade.createWorkspace({
3232
workspaceName: state.workspaceTemplateChosen.displayName,
3333
workspaceTemplateName: state.workspaceTemplateChosen.value,
3434
opts: { },

libs/remix-ui/template-explorer-modal/src/components/template-explorer.tsx

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import isElectron from 'is-electron'
22
import React, { useContext, useEffect } from 'react'
33
import { TemplateCategory, TemplateExplorerProps, TemplateExplorerWizardAction, TemplateItem } from '../../types/template-explorer-types'
44
import { TemplateExplorerContext } from '../../context/template-explorer-context'
5-
import { CookbookStrategy, GenAiStrategy, GenericStrategy, RemixDefaultStrategy, WizardStrategy } from '../../stategies/templateCategoryStrategy'
5+
import { TemplateExplorerModalFacade } from '../utils/workspaceUtils'
66

77
export function TemplateExplorer() {
88

9-
const { metadata, dedupedTemplates, addRecentTemplate, plugin, dispatch, state, templateCategoryStrategy } = useContext(TemplateExplorerContext)
9+
const { metadata, dedupedTemplates, plugin, dispatch, facade, templateCategoryStrategy } = useContext(TemplateExplorerContext)
1010

1111
return (
1212
<div className="template-explorer-container overflow-y-auto" style={{ height: '350px', padding: '1rem' }}>
@@ -55,29 +55,7 @@ export function TemplateExplorer() {
5555
flexDirection: 'column'
5656
}}
5757
onClick={() => {
58-
dispatch({ type: TemplateExplorerWizardAction.SELECT_TEMPLATE, payload: item })
59-
dispatch({ type: TemplateExplorerWizardAction.SET_WORKSPACE_TEMPLATE_GROUP, payload: template.name })
60-
dispatch({ type: TemplateExplorerWizardAction.SET_WORKSPACE_NAME, payload: item.value })
61-
if (template.name.toLowerCase() === 'generic' && !item.value.toLowerCase().includes('remixaitemplate') && item.value !== 'remixDefault') {
62-
templateCategoryStrategy.setStrategy(new GenericStrategy())
63-
templateCategoryStrategy.switchScreen(dispatch)
64-
} else if (template.name.toLowerCase() === 'generic' && item.value.toLowerCase().includes('remixaitemplate')) {
65-
templateCategoryStrategy.setStrategy(new GenAiStrategy())
66-
templateCategoryStrategy.switchScreen(dispatch)
67-
} else if (template.name.toLowerCase() === 'generic' && item.value === 'remixDefault') {
68-
console.log('remixdefault')
69-
templateCategoryStrategy.setStrategy(new RemixDefaultStrategy())
70-
templateCategoryStrategy.switchScreen(dispatch)
71-
} else if (template.name.toLowerCase().includes('zeppelin')) {
72-
templateCategoryStrategy.setStrategy(new WizardStrategy())
73-
templateCategoryStrategy.switchScreen(dispatch)
74-
} else if (template.name.toLowerCase().includes('cookbook')) {
75-
templateCategoryStrategy.setStrategy(new CookbookStrategy())
76-
templateCategoryStrategy.switchScreen(dispatch)
77-
} else if (template.name.toLowerCase() !== 'generic' && template.name.toLowerCase() !== 'zeppelin' && template.name.toLowerCase() !== 'cookbook') {
78-
templateCategoryStrategy.setStrategy(new GenericStrategy())
79-
templateCategoryStrategy.switchScreen(dispatch)
80-
}
58+
facade.switchWizardScreen(dispatch, item, template, templateCategoryStrategy)
8159
}}
8260
onMouseEnter={(e) => {
8361
e.currentTarget.style.boxShadow = '0 4px 8px rgba(0,0,0,0.15)'

libs/remix-ui/template-explorer-modal/src/components/topCards.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import React from 'react'
1+
import React, { useContext } from 'react'
2+
import { TemplateExplorerContext } from '../../context/template-explorer-context'
3+
import { TemplateExplorerWizardAction } from '../../types/template-explorer-types'
24

35
export function TopCards() {
6+
const { state, dispatch } = useContext(TemplateExplorerContext)
7+
48
return (
59
<div className="title">
610
<div className="d-flex flex-row flex-wrap justify-content-center align-items-center gap-3 mb-3">
711
<div
812
className={`explora-topcard d-flex flex-row align-items-center bg-light p-4 shadow-sm border-0`}
9-
onClick={() => {}}
13+
onClick={() => {
14+
dispatch({ type: TemplateExplorerWizardAction.SET_WIZARD_STEP, payload: 'generic' })
15+
}}
1016
style={{
1117
borderRadius: '10px',
1218
height: '76px',
@@ -31,7 +37,9 @@ export function TopCards() {
3137
</div>
3238
<div
3339
className={`explora-topcard d-flex flex-row align-items-center bg-light p-4 shadow-sm border-0`}
34-
onClick={() => {}}
40+
onClick={() => {
41+
dispatch({ type: TemplateExplorerWizardAction.SET_WIZARD_STEP, payload: 'genAI' })
42+
}}
3543
style={{
3644
borderRadius: '10px',
3745
height: '76px',
@@ -56,7 +64,9 @@ export function TopCards() {
5664
</div>
5765
<div
5866
className={`explora-topcard d-flex flex-row align-items-center bg-light p-4 shadow-sm border-0`}
59-
onClick={() => {}}
67+
onClick={() => {
68+
dispatch({ type: TemplateExplorerWizardAction.SET_WIZARD_STEP, payload: 'wizard' })
69+
}}
6070
style={{
6171
borderRadius: '10px',
6272
height: '76px',
@@ -81,7 +91,9 @@ export function TopCards() {
8191
</div>
8292
<div
8393
className={`explora-topcard d-flex flex-row align-items-center bg-light p-4 shadow-sm border-0`}
84-
onClick={() => {}}
94+
onClick={() => {
95+
dispatch({ type: TemplateExplorerWizardAction.SET_WIZARD_STEP, payload: 'import' })
96+
}}
8597
style={{
8698
borderRadius: '10px',
8799
height: '76px',

libs/remix-ui/template-explorer-modal/src/components/workspaceDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface WorkspaceDetailsProps {
1010
}
1111

1212
export function WorkspaceDetails(props: WorkspaceDetailsProps) {
13-
const { state, dispatch, makeWorkspace } = useContext(TemplateExplorerContext)
13+
const { state, dispatch, facade } = useContext(TemplateExplorerContext)
1414

1515
return (
1616
<section className="d-flex flex-column gap-3 bg-light" style={{ height: '80%' }}>
@@ -52,7 +52,7 @@ export function WorkspaceDetails(props: WorkspaceDetailsProps) {
5252

5353
<button className="btn btn-primary btn-sm" data-id="validateWorkspaceButton" onClick={async () => {
5454
console.log('about to create workspace')
55-
await makeWorkspace.createWorkspace({
55+
await facade.createWorkspace({
5656
workspaceName: state.workspaceTemplateChosen.displayName,
5757
workspaceTemplateName: state.workspaceTemplateChosen.value,
5858
opts: { },

0 commit comments

Comments
 (0)