docs: create docs workspace (#5174)

* docs: migrate ui docs to docs universe

* created yarn workspace

* added eslint and tsconfig configurations

* fix eslint configurations

* fixed eslint configurations

* shared tailwind configurations

* added shared ui package

* added more shared components

* migrating more components

* made details components shared

* move InlineCode component

* moved InputText

* moved Loading component

* Moved Modal component

* moved Select components

* Moved Tooltip component

* moved Search components

* moved ColorMode provider

* Moved Notification components and providers

* used icons package

* use UI colors in api-reference

* moved Navbar component

* used Navbar and Search in UI docs

* added Feedback to UI docs

* general enhancements

* fix color mode

* added copy colors file from ui-preset

* added features and enhancements to UI docs

* move Sidebar component and provider

* general fixes and preparations for deployment

* update docusaurus version

* adjusted versions

* fix output directory

* remove rootDirectory property

* fix yarn.lock

* moved code component

* added vale for all docs MD and MDX

* fix tests

* fix vale error

* fix deployment errors

* change ignore commands

* add output directory

* fix docs test

* general fixes

* content fixes

* fix announcement script

* added changeset

* fix vale checks

* added nofilter option

* fix vale error
This commit is contained in:
Shahed Nasser
2023-09-21 20:57:15 +03:00
committed by GitHub
parent 19c5d5ba36
commit fa7c94b4cc
3209 changed files with 32188 additions and 31018 deletions
@@ -0,0 +1,80 @@
"use client"
import React, { useRef, useState } from "react"
import clsx from "clsx"
import { Star, StarSolid } from "@medusajs/icons"
import { Button } from "@/components"
import { useAnalytics } from "@/providers"
export type RatingProps = {
event?: string
className?: string
onRating?: () => void
} & React.HTMLAttributes<HTMLDivElement>
export const Rating: React.FC<RatingProps> = ({
event = "rating",
className = "",
onRating,
}) => {
const [rating, setRating] = useState(0)
const [hoverRating, setHoverRating] = useState(0)
const starElms = useRef<HTMLElement[]>([])
const starArr = Array.from(Array(5).keys())
const { track } = useAnalytics()
const handleRating = (selectedRating: number) => {
if (rating) {
return
}
setHoverRating(0)
setRating(selectedRating)
for (let i = 0; i < selectedRating; i++) {
starElms.current[i].classList.add("animate-tada")
}
track(
event,
{
rating: selectedRating,
},
() => onRating?.()
)
}
return (
<div className={clsx("flex gap-docs_0.5", className)}>
{starArr.map((i) => {
const isSelected =
(rating !== 0 && rating - 1 >= i) ||
(hoverRating !== 0 && hoverRating - 1 >= i)
return (
<Button
variant="clear"
buttonRef={(element) => {
if (starElms.current.length - 1 < i) {
starElms.current.push(element as HTMLElement)
}
}}
key={i}
onMouseOver={() => {
if (!rating) {
setHoverRating(i + 1)
}
}}
onMouseLeave={() => {
if (!rating) {
setHoverRating(0)
}
}}
onClick={() => handleRating(i + 1)}
>
{!isSelected && <Star />}
{isSelected && (
<StarSolid className="text-medusa-tag-orange-icon dark:text-medusa-tag-orange-icon-dark" />
)}
</Button>
)
})}
</div>
)
}