Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add react-rating star component #138

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './globals.css';
import '@smastrom/react-rating/style.css';

import type { Metadata, Viewport } from 'next';

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@coinbase/onchainkit": "^0.6.1",
"@next/bundle-analyzer": "^14.1.0",
"@nextui-org/react": "^2.2.9",
"@smastrom/react-rating": "^1.5.0",
"@tanstack/react-query": "^5.24.2",
"@tanstack/react-virtual": "^3.0.2",
"class-variance-authority": "^0.7.0",
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 24 additions & 21 deletions src/orgs/components/org-reviews/aggregate-ratings-card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Rating, RoundedStar } from '@smastrom/react-rating';

import { DetailsPanelCardWrapper } from '~/shared/components/details-panel/card-wrapper';
import { Heading } from '~/shared/components/heading';
import { Text } from '~/shared/components/text';

import { ORG_RATING_LABELS } from '~/orgs/core/constants';
import { OrgDetails } from '~/orgs/core/schemas';
Expand All @@ -21,17 +24,6 @@ export const AggregateRatingsCard = ({
([, rating]) => rating !== null,
) as [string, number][];

// const ratings = Object.entries({
// benefits: null,
// careerGrowth: 4.5,
// diversityInclusion: 3.9,
// management: 3.4,
// product: 3.3,
// compensation: 4.9,
// onboarding: 4.6,
// workLifeBalance: null,
// }).filter(([, rating]) => rating !== null) as [string, number][];

return (
<DetailsPanelCardWrapper>
<Heading text={HEADING_TEXT} />
Expand All @@ -44,16 +36,21 @@ export const AggregateRatingsCard = ({
key={label}
className="flex shrink-0 flex-wrap items-center justify-start gap-2"
>
<p>{rating.toFixed(1)}</p>
{/* <Rating
count={1}
fractions={5}
value={(rating ?? 0) / 5}
color="gold"
/> */}
<p className="shrink-0">
{ORG_RATING_LABELS[label as keyof typeof ORG_RATING_LABELS]}
</p>
<Text
className="text-base font-bold text-white"
text={rating.toFixed(1)}
/>
<Rating
readOnly
value={rating}
style={{ maxWidth: 120 }}
itemStyles={RATING_ITEM_STYLES}
/>

<Text
className="shrink-0 text-base text-white"
text={ORG_RATING_LABELS[label as keyof typeof ORG_RATING_LABELS]}
/>
</div>
))}
</div>
Expand All @@ -64,3 +61,9 @@ export const AggregateRatingsCard = ({
};

const HEADING_TEXT = 'Aggregate Ratings';

const RATING_ITEM_STYLES = {
itemShapes: RoundedStar,
activeFillColor: '#ffb700',
inactiveFillColor: '#3f3f3f',
};
Loading