-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3641 from SigNoz/release/v0.30.0
Release/v0.30.0
- Loading branch information
Showing
138 changed files
with
3,255 additions
and
1,441 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Ignore artifacts: | ||
build | ||
coverage | ||
|
||
# Ignore all MD files: | ||
**/*.md |
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
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
34 changes: 34 additions & 0 deletions
34
frontend/src/components/MarkdownRenderer/CodeCopyBtn/CodeCopyBtn.scss
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,34 @@ | ||
.code-snippet-container { | ||
position: relative; | ||
background-color: rgb(43, 43, 43); | ||
} | ||
|
||
.code-copy-btn { | ||
position: absolute; | ||
top: 8px; | ||
right: 8px; | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: center; | ||
|
||
button { | ||
cursor: pointer; | ||
|
||
background-color: rgba($color: #1d1d1d, $alpha: 0.7); | ||
color: white; | ||
border: none; | ||
padding: 8px; | ||
border-radius: 3px; | ||
transition: all 0.1s; | ||
|
||
&:hover { | ||
background-color: rgba($color: #1d1d1d, $alpha: 1); | ||
} | ||
} | ||
|
||
&.copied { | ||
button { | ||
background-color: rgba($color: #52c41a, $alpha: 1); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
frontend/src/components/MarkdownRenderer/CodeCopyBtn/CodeCopyBtn.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,32 @@ | ||
import './CodeCopyBtn.scss'; | ||
|
||
import { CheckOutlined, CopyOutlined } from '@ant-design/icons'; | ||
import cx from 'classnames'; | ||
import { useState } from 'react'; | ||
|
||
export default function CodeCopyBtn({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}): JSX.Element { | ||
const [isSnippetCopied, setIsSnippetCopied] = useState(false); | ||
|
||
const handleClick = (): void => { | ||
if (children && Array.isArray(children)) { | ||
setIsSnippetCopied(true); | ||
navigator.clipboard.writeText(children[0].props.children[0]).finally(() => { | ||
setTimeout(() => { | ||
setIsSnippetCopied(false); | ||
}, 1000); | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={cx('code-copy-btn', isSnippetCopied ? 'copied' : '')}> | ||
<button type="button" onClick={handleClick}> | ||
{!isSnippetCopied ? <CopyOutlined /> : <CheckOutlined />} | ||
</button> | ||
</div> | ||
); | ||
} |
43 changes: 43 additions & 0 deletions
43
frontend/src/components/MarkdownRenderer/MarkdownRenderer.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 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
import { CodeProps } from 'react-markdown/lib/ast-to-react'; | ||
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; | ||
import { a11yDark } from 'react-syntax-highlighter/dist/cjs/styles/prism'; | ||
|
||
import CodeCopyBtn from './CodeCopyBtn/CodeCopyBtn'; | ||
|
||
function Pre({ children }: { children: React.ReactNode }): JSX.Element { | ||
return ( | ||
<pre className="code-snippet-container"> | ||
<CodeCopyBtn>{children}</CodeCopyBtn> | ||
{children} | ||
</pre> | ||
); | ||
} | ||
|
||
function Code({ | ||
node, | ||
inline, | ||
className = 'blog-code', | ||
children, | ||
...props | ||
}: CodeProps): JSX.Element { | ||
const match = /language-(\w+)/.exec(className || ''); | ||
return !inline && match ? ( | ||
<SyntaxHighlighter | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
style={a11yDark} | ||
language={match[1]} | ||
PreTag="div" | ||
{...props} | ||
> | ||
{String(children).replace(/\n$/, '')} | ||
</SyntaxHighlighter> | ||
) : ( | ||
<code className={className} {...props}> | ||
{children} | ||
</code> | ||
); | ||
} | ||
|
||
export { Code, Pre }; |
Oops, something went wrong.