-
Notifications
You must be signed in to change notification settings - Fork 177
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
#1044 Text Tool: Add special symbols #1048
Merged
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7fd36a7
Add special symbols button and ability to insert symbols to text tool
362782f
Merge branch 'master' into #1044-Text-Tool-Add-special-symbols
r1z3rISGOD 49db909
Used prettier
42286a7
Merge remote-tracking branch 'origin/#1044-Text-Tool-Add-special-symb…
cf0f8f5
Used stylelint
a48d769
Merge branch 'master' into #1044-Text-Tool-Add-special-symbols
ElenaOdnoshivkina 4948c94
refactoring and renaming of icon
ElenaOdnoshivkina b74bd10
Merge branch 'master' into #1044-Text-Tool-Add-special-symbols
ElenaOdnoshivkina 0807bfa
Merge branch 'master' into #1044-Text-Tool-Add-special-symbols
ElenaOdnoshivkina bd95ddf
fixing problem with formatting of inserted symbols
ElenaOdnoshivkina 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
63 changes: 63 additions & 0 deletions
63
...src/script/ui/views/modal/components/Text/SpecialSymbols/SpecialSymbolsButton.module.less
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,63 @@ | ||
/**************************************************************************** | ||
* Copyright 2021 EPAM Systems | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************/ | ||
|
||
@import '../../../../../../../style/variables'; | ||
@import '../../../../../../../style/mixins'; | ||
|
||
.textButton { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to re-use styles, as styles in TextButton.module.less are basically identical |
||
.btn(); | ||
|
||
border: 0; | ||
padding: 0; | ||
position: relative; | ||
cursor: pointer; | ||
margin: 4px; | ||
.button-size(large); | ||
|
||
& > svg { | ||
fill: #666; | ||
transition: 0.2s; | ||
} | ||
|
||
&:hover { | ||
background-image: none; | ||
& > svg { | ||
fill: #000; | ||
} | ||
} | ||
} | ||
|
||
.button-size(@dim) { | ||
.set-size(@dim); | ||
|
||
width: @button-size; | ||
height: @button-size; | ||
margin: @button-grow; | ||
|
||
& > svg { | ||
position: absolute; | ||
top: 0.1em; | ||
left: 0.1em; | ||
font-size: @icon-size; | ||
width: @icon-size; | ||
height: @icon-size; | ||
} | ||
} | ||
|
||
// stylelint-disable-next-line selector-pseudo-class-no-unknown | ||
:global(.smallEditor) .textButton { | ||
.button-size(small); | ||
} |
58 changes: 58 additions & 0 deletions
58
...r-react/src/script/ui/views/modal/components/Text/SpecialSymbols/SpecialSymbolsButton.tsx
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,58 @@ | ||
/**************************************************************************** | ||
* Copyright 2021 EPAM Systems | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************/ | ||
|
||
import { useState } from 'react' | ||
import { SpecialSymbolsList } from '../SpecialSymbolsList/SpecialSymbolsList' | ||
import classes from './SpecialSymbolsButton.module.less' | ||
import Icon from '../../../../../component/view/icon' | ||
|
||
export interface SpecialSymbolsButtonProps { | ||
select: (symbol: string) => void | ||
} | ||
|
||
const SpecialSymbolsButton = ({ select }: SpecialSymbolsButtonProps) => { | ||
const [showSpecialSymbols, setShowSpecialSymbols] = useState(false) | ||
|
||
const handleClose = event => { | ||
event.stopPropagation() | ||
event.preventDefault() | ||
setShowSpecialSymbols(false) | ||
} | ||
const handleOpen = () => { | ||
setShowSpecialSymbols(true) | ||
} | ||
const closeSymbolsList = event => { | ||
if (!event.currentTarget.contains(event.relatedTarget)) { | ||
handleClose(event) | ||
} | ||
} | ||
return ( | ||
<div onBlur={closeSymbolsList}> | ||
<button | ||
title="symbols" | ||
onClick={handleOpen} | ||
className={classes.textButton} | ||
> | ||
<Icon name="symbols" /> | ||
{showSpecialSymbols && ( | ||
<SpecialSymbolsList hideMenu={handleClose} select={select} /> | ||
)} | ||
</button> | ||
</div> | ||
) | ||
} | ||
|
||
export { SpecialSymbolsButton } |
25 changes: 25 additions & 0 deletions
25
...c/script/ui/views/modal/components/Text/SpecialSymbolsList/SpecialSymbolsList.module.less
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,25 @@ | ||
.window { | ||
position: absolute; | ||
width: 113px; | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
background-color: white; | ||
z-index: 10; | ||
height: 200px; | ||
overflow: auto; | ||
top: 100%; | ||
border-radius: 10px; | ||
} | ||
|
||
.button { | ||
width: 30px; | ||
height: 30px; | ||
border: none; | ||
margin: 1px; | ||
background-color: transparent; | ||
&:hover { | ||
color: white; | ||
background-color: #343434; | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
...react/src/script/ui/views/modal/components/Text/SpecialSymbolsList/SpecialSymbolsList.tsx
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,96 @@ | ||
/**************************************************************************** | ||
* Copyright 2021 EPAM Systems | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************/ | ||
|
||
import classes from './SpecialSymbolsList.module.less' | ||
import { SpecialSymbolsButtonProps } from '../SpecialSymbols/SpecialSymbolsButton' | ||
import React from 'react' | ||
|
||
interface SpecialSymbolsListProps extends SpecialSymbolsButtonProps { | ||
hideMenu: (event: React.MouseEvent<HTMLButtonElement>) => void | ||
} | ||
|
||
const SpecialSymbolsList = ({ select, hideMenu }: SpecialSymbolsListProps) => { | ||
const symbols = [ | ||
'α', | ||
'β', | ||
'γ', | ||
'δ', | ||
'ε', | ||
'ζ', | ||
'η', | ||
'θ', | ||
'ι', | ||
'κ', | ||
'λ', | ||
'μ', | ||
'ν', | ||
'ξ', | ||
'ο', | ||
'π', | ||
'ρ', | ||
'σ', | ||
'τ', | ||
'υ', | ||
'φ', | ||
'χ', | ||
'ψ', | ||
'ω', | ||
'℃', | ||
'℉', | ||
'Å', | ||
'°', | ||
'ħ', | ||
'±', | ||
'‰', | ||
'√', | ||
'←', | ||
'→', | ||
'↚', | ||
'↛', | ||
'↔', | ||
'⇌', | ||
'∏', | ||
'∑', | ||
'∞', | ||
'∂', | ||
'∆', | ||
'∫', | ||
'≈', | ||
'≠', | ||
'≤', | ||
'≥' | ||
] | ||
return ( | ||
<div className={classes.window}> | ||
{symbols.map((symbol, id) => { | ||
return ( | ||
<button | ||
className={classes.button} | ||
key={`symbol-${id}`} | ||
value={symbol} | ||
onClick={event => { | ||
select(symbol) | ||
hideMenu(event) | ||
}} | ||
> | ||
{symbol} | ||
</button> | ||
) | ||
})} | ||
</div> | ||
) | ||
} | ||
export { SpecialSymbolsList } |
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.
Please follow naming convention