-
Notifications
You must be signed in to change notification settings - Fork 19
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
fix : reduce css file size #94
Draft
anonymousRecords
wants to merge
6
commits into
main
Choose a base branch
from
fix/reduce-css-file-size
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.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
980d3c3
chore: add font file
anonymousRecords 29a1c29
style: add basic KaTeX styles
anonymousRecords 4ddfcfb
chore: add output to vite config
anonymousRecords bc66b2c
refactor: provide inline & block component
anonymousRecords bba951a
chore: remove renderEquation utils
anonymousRecords 4e4c7f6
refactor: apply equation to richt text
anonymousRecords 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
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import React from "react"; | ||
import { getColorCss, renderEquation } from "../../utils"; | ||
import { getColorCss } from "../../utils"; | ||
import type { TextArgs, EquationArgs } from "../../types"; | ||
import { Helmet } from "react-helmet"; | ||
import Equation from "../equation"; | ||
|
||
function RichText({ props }: { props: TextArgs[] }) { | ||
if (props.length === 0) { | ||
|
@@ -14,7 +14,11 @@ function RichText({ props }: { props: TextArgs[] }) { | |
text.type === "text" ? ( | ||
<Text key={index} props={text} /> | ||
) : ( | ||
<Equation key={index} props={text as unknown as EquationArgs} /> | ||
<Equation | ||
key={index.toString()} | ||
inline | ||
{...(text as unknown as EquationArgs)} | ||
/> | ||
Comment on lines
+17
to
+21
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. Can I reuse the Equation component in the RichText component? |
||
), | ||
)} | ||
</> | ||
|
@@ -69,26 +73,4 @@ function Text({ props }: { props: TextArgs }) { | |
return <>{renderText(content)}</>; | ||
} | ||
|
||
function Equation({ props }: { props: EquationArgs }) { | ||
const { | ||
equation: { expression }, | ||
} = props; | ||
|
||
return ( | ||
<> | ||
<Helmet> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" | ||
integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" | ||
crossOrigin="anonymous" | ||
/> | ||
</Helmet> | ||
<span | ||
className="notion-equation notion-equation-inline" | ||
dangerouslySetInnerHTML={{ __html: renderEquation(expression) }} | ||
/> | ||
</> | ||
); | ||
} | ||
export default RichText; |
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
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.
p3;
The need for additional props like 'inline' signals a potential for expanding requirements for the TeX component. Rather than limiting props, it appears more beneficial to allow users to handle TeX more freely while providing sensible defaults. This approach gives users the flexibility to extend the component's functionality as their requirements evolve, while maintaining a solid foundation of default behavior.
This pattern aligns better with the principle of extensibility and follows the "open for extension, closed for modification" design principle. By exposing the full capabilities of the underlying TeX component, we empower users to adapt the component to their specific needs without requiring changes to the core implementation.
Benefits of change
Enhanced Type Safety
Direct usage of TeXProps type fully leverages the TeX library's type system
Prevents incorrect props passing at compile time
Provides better TypeScript IntelliSense support
Improved Maintainability
Automatically supports new props when the TeX component is updated
Reduces code overhead by eliminating custom type definitions and prop mappings
Easier to track changes from the underlying library
Better Developer Experience
Full access to all TeX component features (settings, error handling, etc.)
Seamless migration path from existing TeX documentation and code examples
Consistent API with the original library
Styling Flexibility
Composable className prop that merges with default styles
Provides ability to override default styles when needed
Maintains consistent styling structure
Style Customization
Review the hardcoded notion-related classes - may need to make them configurable
Consider implementing a theme provider for global style settings