-
Notifications
You must be signed in to change notification settings - Fork 3
[WEB-8] [EDITOR] Basic Delete Block Functionality #341
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
Open
josh-ramos-22
wants to merge
15
commits into
main
Choose a base branch
from
WEB-8_EDITOR_delete_block_functionality
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8db14ef
initial styling of delete block btn (still quite inelegant)
fe78173
draft implementation of block deletion
82e2a2d
moved deletion handling to seperate function
cda13d6
added key to CMSBlock props with initial rnd num impolementation
f30dbfc
deletion updates seem to work now; further investigation needed
02934bc
added delete block component to ui kit
ed96e93
integrated new Delete block button into ui
c4f3459
removed old mui delete button
dbd1d58
fixed style issue with block width when editing
2cba688
cleanup
432c6ba
added TODOS to build upon initial implementation
f3c4eac
rounded out delete button
7278e41
added DeleteBlock to storybook
f301775
Corrected colour of button
2ad0205
finalised delete block functionality
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
30 changes: 30 additions & 0 deletions
30
frontend/src/cse-ui-kit/DeleteBlock_button/DeleteBlock-Styled.tsx
This file contains hidden or 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,30 @@ | ||
import styled from "styled-components"; | ||
|
||
export type buttonProps = { | ||
background?: string; | ||
isFocused?: boolean | ||
}; | ||
export const StyledButton = styled.div<buttonProps>` | ||
width: 45px; | ||
height: 45px; | ||
margin: 5px; | ||
background: ${(props) => props.background}; | ||
|
||
display: ${(props) => props.isFocused ? "flex" : "none"}; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: 30px; | ||
user-select: none; | ||
|
||
&:hover { | ||
background: #efeef3; | ||
color: black; | ||
transform: scale(1.04); | ||
} | ||
&:active { | ||
background: #c8d1fa; | ||
transform: scale(0.96); | ||
} | ||
|
||
cursor: pointer; | ||
`; |
31 changes: 31 additions & 0 deletions
31
frontend/src/cse-ui-kit/DeleteBlock_button/DeleteBlock.stories.tsx
This file contains hidden or 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,31 @@ | ||
import React from 'react'; | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
|
||
import DeleteBlock from './DeleteBlock'; | ||
|
||
export default { | ||
title: 'CSE-UIKIT/DeleteBlockButton', | ||
component: DeleteBlock, | ||
|
||
argTypes: { | ||
backgroundColor: { control: 'color' }, | ||
}, | ||
} as ComponentMeta<typeof DeleteBlock>; | ||
|
||
const Template: ComponentStory<typeof DeleteBlock> = (args) => | ||
( | ||
<div | ||
style={{ | ||
margin: "30px" | ||
}} | ||
> | ||
Delete Button | ||
<DeleteBlock {...args}></DeleteBlock> | ||
</div> | ||
) | ||
|
||
export const Primary = Template.bind({}); | ||
Primary.args = { | ||
background: "#FFF", | ||
isFocused: true | ||
} |
19 changes: 19 additions & 0 deletions
19
frontend/src/cse-ui-kit/DeleteBlock_button/DeleteBlock.tsx
This file contains hidden or 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,19 @@ | ||
import React, { MouseEventHandler } from "react"; | ||
import { StyledButton, buttonProps } from "./DeleteBlock-Styled"; | ||
import { AiOutlineClose } from "react-icons/ai"; | ||
|
||
type Props = { | ||
onClick?: MouseEventHandler<HTMLDivElement>; | ||
} & buttonProps; | ||
|
||
export default function DeleteBlock({ onClick, ...styleProps }: Props) { | ||
return ( | ||
<StyledButton | ||
data-anchor="DeleteBlockButton" | ||
onClick={onClick} | ||
{...styleProps} | ||
> | ||
<AiOutlineClose /> | ||
</StyledButton> | ||
); | ||
} |
This file contains hidden or 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,3 @@ | ||
import DeleteBlock from './DeleteBlock'; | ||
|
||
export default DeleteBlock; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
you can move this entire component into
frontend/src/cse-ui-kit/DeleteBlock_button/index.ts
That way there isn't a need for an empty file with a singular import :DThere 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.
Currently this doesn't work since
index.ts
is ats
file instead of atsx
file :/All of the existing Button components in
cse-ui-kit
(eg CreateContentBlock, CreateHeadingBlock) have an similarindex.ts
file with a single import.Should I change the file to
index.tsx
? Or keep it consistent with the other button components?