Skip to content

Commit

Permalink
add xiehanzi logo using Hanzi Writer
Browse files Browse the repository at this point in the history
  • Loading branch information
krmanik authored Oct 2, 2022
2 parents 7daf28c + 876ff12 commit 1b37a1a
Show file tree
Hide file tree
Showing 3 changed files with 6,391 additions and 6,473 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"clsx": "^1.2.1",
"css-minimizer-webpack-plugin": "^4.1.0",
"docusaurus-plugin-code-preview": "^0.0.1",
"hanzi-writer": "^3.3.0",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
28 changes: 26 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useRef } from 'react';
import clsx from 'clsx';
import Link from '@docusaurus/Link';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
Expand All @@ -8,16 +8,26 @@ import HomepageFeatures from '@site/src/components/HomepageFeatures';
import styles from './index.module.css';
import { HomepageGetStarted, HomepageXiehanziCard } from '../components/HomepageCards';

import HanziWriter from 'hanzi-writer';

function HomepageHeader() {
const ref = useRef()

useEffect(() => {
createXieHanziLogo(ref);
}, []);

const { siteConfig } = useDocusaurusContext();
return (
<header className={clsx('hero', styles.heroBanner)}>
<div className="container">
<div ref={ref}></div>
<h1 className="hero__title">{siteConfig.title}</h1>
<p className="hero__subtitle">{siteConfig.tagline}</p>
<div style={{
display: "inline-flex",
flexWrap: "wrap"
flexWrap: "wrap",
justifyContent: "center"
}}>
<div className={styles.buttons}>
<Link
Expand Down Expand Up @@ -58,3 +68,17 @@ export default function Home(): JSX.Element {
</Layout>
);
}

function createXieHanziLogo(ref) {
let xiehanzi = ["写", "汉", "字"];

for (let hanzi of xiehanzi) {
const writer = HanziWriter.create(ref.current, hanzi, {
width: 80,
height: 80,
padding: 5,
strokeColor: hanzi == "写" ? "#4caf50" : "#2196f3"
})
writer.loopCharacterAnimation();
}
}
Loading

0 comments on commit 1b37a1a

Please sign in to comment.