-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add anchor to titles on dash (#1784)
Co-authored-by: WeblateGravity <[email protected]> Co-authored-by: Darya Tikhonova <[email protected]>
- Loading branch information
1 parent
3b8bbc3
commit ca1347b
Showing
18 changed files
with
439 additions
and
61 deletions.
There are no files selected for viewing
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
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
43 changes: 43 additions & 0 deletions
43
src/ui/components/DashKit/plugins/Title/AnchorLink/AnchorLink.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,43 @@ | ||
import React from 'react'; | ||
|
||
import type {PluginTitleProps} from '@gravity-ui/dashkit'; | ||
import block from 'bem-cn-lite'; | ||
import {useLocation} from 'react-router'; | ||
import {Link} from 'react-router-dom'; | ||
import {DL} from 'ui/constants'; | ||
|
||
import '../Title.scss'; | ||
|
||
const b = block('dashkit-plugin-title-container'); | ||
|
||
interface AnchorLinkProps { | ||
size: PluginTitleProps['data']['size']; | ||
to: string; | ||
show?: boolean; | ||
absolute?: boolean; | ||
top: number; | ||
} | ||
|
||
export const AnchorLink = ({size, to, show, absolute, top}: AnchorLinkProps) => { | ||
const location = useLocation(); | ||
const hash = `#${encodeURIComponent(to)}`; | ||
|
||
const link = {...location, hash}; | ||
|
||
if (DL.IS_MOBILE || !show) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Link | ||
className={b('anchor', { | ||
size, | ||
absolute, | ||
})} | ||
to={link} | ||
style={{top}} | ||
> | ||
# | ||
</Link> | ||
); | ||
}; |
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
Oops, something went wrong.