Skip to content

Commit

Permalink
chore: docs fix & img corss
Browse files Browse the repository at this point in the history
  • Loading branch information
1587315093 committed Oct 31, 2023
1 parent 8222438 commit b4c7b57
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scratch-card-react",
"version": "1.1.0-alpha",
"version": "1.0.0-beta",
"description": "scratch-card-react",
"license": "MIT",
"module": "dist/index.js",
Expand Down
Binary file removed src/assets/react.jpeg
Binary file not shown.
5 changes: 3 additions & 2 deletions src/scratch-card/demo/DemoCop.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FC, ReactNode } from 'react';
import type { CSSProperties, FC, ReactNode } from 'react';

const DemoBlock: FC<{ children: ReactNode; title: string }> = (props) => {
return (
Expand All @@ -9,14 +9,15 @@ const DemoBlock: FC<{ children: ReactNode; title: string }> = (props) => {
);
};

const ChildrenElement = () => (
const ChildrenElement: FC<{ style?: CSSProperties }> = (props) => (
<div
style={{
width: '100%',
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
...props.style,
}}
>
<span>恭喜您,刮中了法拉利5元代金劵</span>
Expand Down
9 changes: 7 additions & 2 deletions src/scratch-card/demo/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ScratchCard } from 'scratch-card-react';
import ReactImg from '../../assets/react.jpeg';
import { ChildrenElement, DemoBlock } from './DemoCop';

export default () => {
Expand All @@ -23,7 +22,13 @@ export default () => {
</ScratchCard>
</DemoBlock>
<DemoBlock title="设置蒙版为图片">
<ScratchCard width={260} height={180} coverImg={ReactImg}>
<ScratchCard
width={260}
height={226}
coverImg={
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
}
>
<ChildrenElement />
</ScratchCard>
</DemoBlock>
Expand Down
8 changes: 5 additions & 3 deletions src/scratch-card/demo/demo2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ export default () => {
<ScratchCard
ref={cardRef}
width={260}
height={180}
coverImg={import('../../assets/react.jpeg')}
height={226}
coverImg={
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
}
callbackInfo={{
radio: 0.8,
calllback: () => {
alert('scratch done');
},
}}
>
<ChildrenElement />
<ChildrenElement style={{ backgroundColor: 'red' }} />
</ScratchCard>
<button
style={{
Expand Down
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export function loadImage(url: string): Promise<HTMLImageElement> {
return new Promise((resolve, reject) => {
const img = new Image();
img.src = url;
img.setAttribute('crossOrigin', '');
img.onload = () => resolve(img);
img.onerror = reject;
});
Expand Down

0 comments on commit b4c7b57

Please sign in to comment.