Skip to content

song-ku-hae-hyeon/BTB

Repository files navigation

Breaking The Browser (BTB)

How to Use

WIP

Download

WIP

How to Develop

WIP

Setting

WIP

Add Tool

  1. public 폴더에 64px 의 png 이미지λ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€.
  • ν•„μˆ˜: 독바 이미지
  • μ˜΅μ…˜: μ»€μ„œ 이미지
  • μ˜΅μ…˜: 마크 이미지
  1. static/IMAGE.ts μ—μ„œ κΈ°μ‘΄ μ½”λ“œλ₯Ό μ°Έκ³ ν•˜μ—¬ 이미지 Url을 μΆ”κ°€ν•©λ‹ˆλ‹€.

  2. 툴 νƒ€μž…μ„ μΆ”κ°€ν•©λ‹ˆλ‹€.

// types/tool
export type ToolType = 'none' | 'highlighter' | ... | 'newTool'
  1. 각 이미지λ₯Ό ν•„μš”ν•œκ³³μ— μΆ”κ°€ν•©λ‹ˆλ‹€.
  • ContentWrapper.styled.ts μ—μ„œ μ»€μ„œ 이미지λ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€.
  • IconButton.styled.ts μ—μ„œ 독바 μ•„μ΄μ½˜μ„ μΆ”κ°€ν•©λ‹ˆλ‹€.
  1. Konva Layer μ»΄ν¬λ„ŒνŠΈλ₯Ό μž‘μ„±ν•©λ‹ˆλ‹€.
const MyNewTool = ({ stageRef }: MyNewToolProps) => {
  const layerRef = useRef<Konva.Layer>(null);
  const { ants, killIfInRange } = useAntKiller(MARK_SIZE, MARK_SIZE);
  const { shakeBrowser } = useShake();

  const callbackFunc = (clientX: number, clientY: number, offset: number) => {
    // ...
    shakeBrowser(100);
    killIfInRange(clientX - offset / 2, clientY);
  };
  useTurn({ stageRef, layerRef, callback: callbackFunc, offset }); // or useMove

  return <Layer ref={layerRef}>...</Layer>;
};

export default MyNewTool;
  • ν•„μš”μ— 따라 useAntKiller, useShake, useTurn, useMove λ“±μ˜ μ»€μŠ€ν…€ 훅을 μ‚¬μš©ν•©λ‹ˆλ‹€.
  1. DockBar에 μƒˆλ‘œμš΄ μ•„μ΄μ½˜μ„ λ“±λ‘ν•©λ‹ˆλ‹€.
const DockBar = ({ selectTool }: DockBarProps) => {
  const onClickBtn = (tool: ToolType) => selectTool(tool);

  return (
    <S.DockBarWrapper>
      <IconButton icon="highlighter" onClickBtn={() => onClickBtn('highlighter')} />
      ///
      <IconButton icon="newTool" onClickBtn={() => onClickBtn('newTool')} />
    </S.DockBarWrapper>
  );
};
  1. ContentApp 에 λ§Œλ“  μ»΄ν¬λ„ŒνŠΈλ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€.

About

Breaking the browser!!!πŸ”¨πŸ”«πŸœ

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •