Skip to content

Commit

Permalink
remove lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-20 committed Mar 23, 2024
1 parent b6da86c commit d0037aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash';
import { useState } from 'react';
import { useInterval, useUpdate } from 'react-use';
import styled from 'styled-components';
Expand All @@ -12,7 +11,9 @@ const IMAGE_HEIGHT = 1518;
const MIN_VIEWER_HEIGHT = 500;
const MAX_VIEWER_HEIGHT = 650;

const MIN_PAGE_WIDTH = _.floor((MIN_VIEWER_HEIGHT / IMAGE_HEIGHT) * IMAGE_WIDTH);
const clamp = (value: number, min: number, max: number) => Math.max(min, Math.min(max, value));

const MIN_PAGE_WIDTH = Math.floor((MIN_VIEWER_HEIGHT / IMAGE_HEIGHT) * IMAGE_WIDTH);

const _Container = styled.div`
position: relative;
Expand Down Expand Up @@ -49,7 +50,7 @@ export const ComicViewer: React.FC<Props> = ({ episodeId }) => {
// 1ページの高さの候補
const candidatePageHeight = (candidatePageWidth / IMAGE_WIDTH) * IMAGE_HEIGHT;
// ビュアーの高さ
const viewerHeight = _.clamp(candidatePageHeight, MIN_VIEWER_HEIGHT, MAX_VIEWER_HEIGHT);
const viewerHeight = clamp(candidatePageHeight, MIN_VIEWER_HEIGHT, MAX_VIEWER_HEIGHT);

return (
<_Container ref={ref}>
Expand Down
7 changes: 3 additions & 4 deletions workspaces/app/src/pages/TopPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash';
import React, { Suspense, useId } from 'react';

import { BookCard } from '../../features/book/components/BookCard';
Expand Down Expand Up @@ -39,7 +38,7 @@ const TopPage: React.FC = () => {
<Spacer height={Space * 2} />
<Box maxWidth="100%" overflowX="scroll" overflowY="hidden">
<Flex align="stretch" direction="row" gap={Space * 2} justify="flex-start">
{_.map(featureList, (feature) => (
{featureList.map((feature) => (
<FeatureCard key={feature.id} bookId={feature.book.id} />
))}
</Flex>
Expand All @@ -55,7 +54,7 @@ const TopPage: React.FC = () => {
<Spacer height={Space * 2} />
<Box maxWidth="100%" overflowX="hidden" overflowY="hidden">
<Flex align="center" as="ul" direction="column" justify="center">
{_.map(rankingList, (ranking) => (
{rankingList.map((ranking) => (
<RankingCard key={ranking.id} bookId={ranking.book.id} />
))}
</Flex>
Expand All @@ -71,7 +70,7 @@ const TopPage: React.FC = () => {
<Spacer height={Space * 2} />
<Box maxWidth="100%" overflowX="scroll" overflowY="hidden">
<Flex align="stretch" gap={Space * 2} justify="flex-start">
{_.map(release.books, (book) => (
{release.books.map((book) => (
<BookCard key={book.id} bookId={book.id} />
))}
</Flex>
Expand Down

0 comments on commit d0037aa

Please sign in to comment.