Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
happylolonly committed May 29, 2024
1 parent 7247578 commit af6a1a4
Show file tree
Hide file tree
Showing 10 changed files with 1,179 additions and 13 deletions.
7 changes: 7 additions & 0 deletions front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,25 @@
"dependencies": {
"@aws-crypto/sha256-js": "^5.0.0",
"@cosmjs/encoding": "^0.32.3",
"@cybercongress/cyber-js": "^0.4.0",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@ethereumjs/tx": "^5.3.0",
"@ethereumjs/util": "^9.0.3",
"@hookform/resolvers": "^3.3.4",
"@mui/material": "^5.14.1",
"@orbs-network/ton-access": "^2.3.3",
"@supabase/supabase-js": "^2.39.8",
"@tanstack/react-query": "^5.40.0",
"@ton/core": "^0.56.1",
"@ton/crypto": "^3.2.0",
"@ton/ton": "^13.11.1",
"@tonconnect/ui-react": "^2.0.0-beta.2",
"@vercel/analytics": "^1.2.2",
"@vkruglikov/react-telegram-web-app": "^2.1.1",
"axios": "^1.5.0",
"classnames": "^2.5.1",
"eslint-plugin-simple-import-sort": "^12.0.0",
"framer-motion": "^10.16.4",
"react": "^18.2.0",
Expand All @@ -42,6 +47,8 @@
"styled-components": "^6.0.5",
"swr": "^2.2.2",
"telegraf": "^4.12.2",
"tone": "^15.0.4",
"uuid": "^9.0.1",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
24 changes: 20 additions & 4 deletions front/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,32 @@ import Router from "@/components/common/Router";
import { network } from "@/hooks/contract/useTonClient";
import GlobalStyle from "@/styles/globalStyles";
import theme from "@/styles/theme";
import QueryClientProvider2 from "./queryClient";

import { QueryClientProvider, QueryClient } from "@tanstack/react-query";

console.log(`You're connected to the ${network} network!`);

const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
// staleTime: 60 * 1000,
},
},
});

const App = () => {
return (
<ThemeProvider theme={theme}>
<RecoilRoot>
<GlobalStyle />
<Router />
</RecoilRoot>
<QueryClientProvider client={queryClient}>
<QueryClientProvider2>
<RecoilRoot>
<GlobalStyle />
<Router />
</RecoilRoot>
</QueryClientProvider2>
</QueryClientProvider>
</ThemeProvider>
);
};
Expand Down
77 changes: 77 additions & 0 deletions front/src/components/MusicalAddress/MusicalAddress.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.containerSignaturesBtnPlay {
width: fit-content;
background: transparent;
border: unset;
// height: 20px;
font-size: 16px;
// padding: 100px;
color: var(--primary-color);

&.disabled {
color: rgba(255, 255, 255, 0.78);
}

&:hover:not(.disabled) {
a {
color: #00ffbf;
}
}
}

.containerSignatures,
.music {
display: flex;

align-items: center;
gap: 3px;
}

.containerSignatures {
&ItemNote {
width: 7px;
border-radius: 2px;
max-height: 20px;

@media (max-width: 800px) {
width: 5px;
}
}

@media (max-width: 800px) {
gap: 2px;
}
}

$items: 32;

.containerSignaturesPlaying {
.containerSignaturesItemNote {
opacity: 1;
animation: blink 0.3s;
animation-fill-mode: both;
animation-timing-function: ease-in-out;

@for $i from 1 through $items {
&:nth-child(#{$i}) {
animation-delay: $i * 0.2s;
}
}
}
}

@keyframes blink {
0% {
opacity: 0.2;
}

50% {
opacity: 1;
}

100% {
opacity: 0.2;
}
// 100% {
// opacity: 1;
// }
}
57 changes: 57 additions & 0 deletions front/src/components/MusicalAddress/MusicalAddress.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* eslint-disable import/no-unused-modules */

import { Meta, StoryObj } from '@storybook/react';

import MusicalAddress from './MusicalAddress';

const stubAddress = 'bostrom1f5warat4vc0q98k7ygys4saka8u04rfxpmthvl';
const stubAddress2 = 'cosmos1f5warat4vc0q98k7ygys4saka8u04rfxzglyjc';
const stubAddress3 = 'osmo1f5warat4vc0q98k7ygys4saka8u04rfx2nv5y2';
const stubAddress4 = '0xbb5913bb6fa84f02ce78ffeeb9e7d43e3d075b16';

const meta: Meta<typeof MusicalAddress> = {
component: MusicalAddress,
title: 'atoms/MusicalAddress',
parameters: {
design: {
type: 'figma',
url: 'https://www.figma.com/file/7i0Ly3YF587km0F8iDZod4/cyb?type=design&node-id=17023-16986',
},
},
};
export default meta;

type Story = StoryObj<typeof MusicalAddress>;

const defaultArgs = {
address: stubAddress,
};

export const Default: Story = {
args: defaultArgs,
};

export const Group: Story = {
render: () => {
return (
<div
style={{
display: 'grid',
gap: '30px 0',
}}
>
<MusicalAddress {...defaultArgs} />
<MusicalAddress address={stubAddress2} />
<MusicalAddress address={stubAddress3} />
<MusicalAddress address={stubAddress4} disabled />
</div>
);
},
};

export const Disabled: Story = {
args: {
...defaultArgs,
disabled: true,
},
};
134 changes: 134 additions & 0 deletions front/src/components/MusicalAddress/MusicalAddress.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { useMemo, useState, useCallback } from "react";
import { v4 as uuidv4 } from "uuid";
import styles from "./MusicalAddress.module.scss";
import {
DICTIONARY_ABC,
getHeight,
getNoteFromAdd,
makeSound,
cutAddress,
} from "./utils";
import { Link } from "react-router-dom";
import { Tooltip } from "src/components";
// import Pill from '../Pill/Pill';

import classNames from "classnames";

type Props = {
address: string;
disabled?: boolean;
};

function MusicalAddress({ address: bech32, disabled }: Props) {
const [playing, setPlaying] = useState(true);
const [addressCopied, setAddressCopied] = useState(false);

const address = useMemo(() => {
return cutAddress(bech32);
}, [bech32]);

const useGetItems = useMemo(() => {
const items = [];

if (address !== null) {
const { address: sliceAddress } = address;
const arrayAddress = sliceAddress.split("");
const bufferAddress = window.Buffer.from(sliceAddress)
.toString("hex")
.replace(/[a-z]/g, "")
.split("");
arrayAddress.forEach((item, index) => {
items.push({
color: DICTIONARY_ABC[item].color,
code: bufferAddress[index] || 2,
});
});
}

return items;
}, [address]);

const copyAddress = useCallback(() => {
navigator.clipboard.writeText(bech32);

setAddressCopied(true);

setTimeout(() => {
setAddressCopied(false);
}, 3000);
}, [bech32]);

const onClickMusicalAddress = useCallback(() => {
if (!playing) {
return;
}

if (address) {
copyAddress();
const { address: sliceAddress } = address;
const arrNote = getNoteFromAdd(sliceAddress);
setPlaying(false);
makeSound(arrNote);
setTimeout(() => {
setPlaying(true);
}, 7000);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [address, playing]);

function renderAddressPart(text: string) {
if (disabled) {
return text;
}

return <Link to={`/neuron/${bech32}`}>{text}</Link>;
}

return (
<div
className={classNames(styles.containerSignaturesBtnPlay, {
[styles.disabled]: disabled,
})}
>
<div
className={classNames(styles.containerSignatures, {
[styles.containerSignaturesPlaying]: !playing,
})}
>
{address && renderAddressPart(address.prefix)}

<div>
{/* <Tooltip
strategy="fixed"
tooltip={!addressCopied ? 'copy address' : 'address copied!'}
> */}
<button
className={styles.music}
onClick={onClickMusicalAddress}
type="button"
>
{useGetItems.map((item) => {
const key = uuidv4();
return (
<div
key={key}
className={styles.containerSignaturesItemNote}
style={{
background: item.color,
color: item.color,
height: `${getHeight(item.code)}px`,
}}
/>
);
})}
</button>
{/* </Tooltip> */}
</div>

{address && renderAddressPart(address.end)}
</div>
</div>
);
}

export default MusicalAddress;
Loading

0 comments on commit af6a1a4

Please sign in to comment.