-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: move template selection into modal UI #201
Merged
asyncapi-bot
merged 18 commits into
asyncapi:master
from
boyney123:moving-template-selection-into-modals
Feb 2, 2022
Merged
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c647871
moving template selection into modals
f1ce045
Update src/components/Modals/NewFileModal.tsx
boyney123 3c490da
Update src/components/Modals/NewFileModal.tsx
boyney123 4c1b74a
making small suggestion changes
f2801e6
Merge branch 'moving-template-selection-into-modals' of github.com:bo…
0b05d15
fixing merge
775c0f9
fixing merge
87e79a7
removing the dashed borders
53754fd
merge
734045c
fixing merge
d338186
update to package-lock.json
404bb10
update to package-lock.json
407c0c4
Merge branch 'master' into moving-template-selection-into-modals
boyney123 883566d
removed duplicate code
dfca533
Update src/components/Modals/NewFileModal.tsx
boyney123 9963493
Merge branch 'master' into moving-template-selection-into-modals
magicmatatjahu b4f2869
apply fixes
magicmatatjahu 14273f1
apply fixes
magicmatatjahu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import React, { useState } from 'react'; | ||
import { BsFillCheckCircleFill } from 'react-icons/bs'; | ||
import toast from 'react-hot-toast'; | ||
|
||
import { ConfirmModal } from './index'; | ||
import examples from '../../examples'; | ||
import { EditorService } from '../../services'; | ||
import state from '../../state'; | ||
|
||
export const NewFileModal: React.FunctionComponent = () => { | ||
const sidebarState = state.useSidebarState(); | ||
const [selectedTemplate, setSelectedTemplate] = useState({ title: '', template: '' }); | ||
|
||
const handleSubmit = () => { | ||
EditorService.updateState({ content: selectedTemplate.template, updateModel: true }); | ||
const panels = state.sidebar.panels; | ||
panels.merge({ | ||
newFile: false, | ||
}); | ||
|
||
toast.success( | ||
<div> | ||
<span className="block text-bold"> | ||
Succesfully reused the {`"${selectedTemplate.title}"`} template. | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
const realLifeExamples = examples.filter((template) => template.type === 'real-example'); | ||
const templates = examples.filter((template) => template.type === 'protocol-example'); | ||
|
||
return ( | ||
<ConfirmModal containerClassName="sm:max-w-6xl" onCancel={() => sidebarState.panels.newFile.set(false)} title="AsyncAPI Templates - Start with our template examples" confirmText="Use Template" confirmDisabled={false} show={true} onSubmit={handleSubmit}> | ||
<div className="flex content-center justify-center"> | ||
<div className="w-full overflow-auto space-y-8 "> | ||
<div> | ||
<span className="uppercase text-gray-800 text-sm underline font-bold">Templates</span> | ||
<div className="grid grid-cols-3 gap-4 py-4"> | ||
{templates.map(({ title, description: Description, template }) => { | ||
const isSelected = selectedTemplate.title === title; | ||
const containerStyles = isSelected ? 'border-pink-500' : 'border-gray-200'; | ||
const textStyles = isSelected ? 'text-pink-600' : 'text-gray-600'; | ||
|
||
return ( | ||
<button | ||
onClick={() => setSelectedTemplate({ title, template })} | ||
key={title} | ||
className={`group text-left flex flex-col cursor-pointer rounded-lg p-4 pb-6 border-2 hover:border-pink-500 ${containerStyles}`} | ||
> | ||
<div className="flex justify-between w-full"> | ||
<span className={`block text-md font-bold leading-0 group-hover:text-pink-600 ${textStyles} `}>{title}</span> | ||
{isSelected && <BsFillCheckCircleFill className="w-5 h-5 text-pink-600" />} | ||
</div> | ||
<span className="block text-sm text-gray-500 font-light mt-1 group-hover:text-gray-900"> | ||
<Description /> | ||
</span> | ||
</button> | ||
); | ||
})} | ||
boyney123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
</div> | ||
<div> | ||
<span className="uppercase text-gray-800 text-sm underline font-bold">Real world Examples</span> | ||
<div className="grid grid-cols-3 gap-4 py-4"> | ||
{realLifeExamples.map(({ title, description: Description, template }) => { | ||
const isSelected = selectedTemplate.title === title; | ||
const containerStyles = isSelected ? 'border-pink-500' : 'border-gray-200'; | ||
const textStyles = isSelected ? 'text-pink-600' : 'text-gray-600'; | ||
|
||
return ( | ||
<button | ||
onClick={() => setSelectedTemplate({ title, template })} | ||
key={title} | ||
className={`group text-left flex flex-col cursor-pointer rounded-lg p-4 pb-6 border-2 border-gray-200 hover:border-pink-500 ${containerStyles}`} | ||
> | ||
<div className="flex justify-between w-full"> | ||
<span className={`block text-md font-bold leading-0 group-hover:text-pink-600 ${textStyles} `}>{title}</span> | ||
{isSelected && <BsFillCheckCircleFill className="w-5 h-5 text-pink-600" />} | ||
</div> | ||
<span className="block text-sm text-gray-500 font-light mt-1 group-hover:text-gray-900"> | ||
<Description /> | ||
</span> | ||
</button> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
<span className=" text-xs block text-gray-900 text-right "> | ||
Don't see what you're looking for? <br /> | ||
<a | ||
target="_blank" | ||
href="https://github.com/asyncapi/studio/issues/new?assignees=&labels=enhancement&template=enhancement.md&title=Template%20Request:%20{%20template%20name%20and%20type%20}" | ||
className="underline text-pink-500" | ||
rel="noreferrer" | ||
> | ||
Request a template or add one to the list → | ||
</a> | ||
</span> | ||
</div> | ||
</div> | ||
</ConfirmModal> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All our modals has that nice enter animation (like settings on the bottom left corner) but templates hasn't and here is a problem. You always destroy and create new React node when user will open that model. I think that we should fix that by:
but we have to "watch" for change
newFileEnabled
in theNewFileModal
component and changeshow
prop to theshow={newFileEnabled}
.