-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[FE] Prep work - Tailwind + shadcn cross integration in LSO + LSE #6870
Open
nick-skriabin
wants to merge
16
commits into
develop
Choose a base branch
from
fb-dia-1783/tailwind
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,043
−20
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
86cc448
Adding tailwind (wip)
nick-skriabin b3ed266
Merge branch 'develop' into tailwind
nick-skriabin d220c4e
Adding Tailwind and shadcn UI
nick-skriabin 4aa7085
Fix global styles
nick-skriabin a3ec3d6
setting up storybook
nick-skriabin f84e442
Merge branch 'develop' into tailwind
nick-skriabin 93cb876
Move Tailwind config to UI lib
nick-skriabin 6318bf6
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin 0a03083
Tailwind and shadcn cross-repo setup
nick-skriabin 9e063ea
Remove testing code
nick-skriabin 2afc869
Rollback unnecessary changes
nick-skriabin 3572a74
Remove dist changes
nick-skriabin 0707aaf
Fix logo size
nick-skriabin 606568d
Properly set up shadcn components installation, remove dist changes
nick-skriabin 88190aa
Restore dist to develop state
nick-skriabin 8dca930
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# syntax=docker/dockerfile:1 | ||
ARG NODE_VERSION=18 | ||
ARG PYTHON_VERSION=3.12 | ||
ARG POETRY_VERSION=1.8.4 | ||
ARG VERSION_OVERRIDE | ||
ARG BRANCH_OVERRIDE | ||
|
||
################################ Overview | ||
|
||
# This Dockerfile builds a Label Studio environment. | ||
# It consists of three main stages: | ||
# 1. "frontend-builder" - Compiles the frontend assets using Node. | ||
# 2. "frontend-version-generator" - Generates version files for frontend sources. | ||
# 3. "venv-builder" - Prepares the virtualenv environment. | ||
# 4. "py-version-generator" - Generates version files for python sources. | ||
# 5. "prod" - Creates the final production image with the Label Studio, Nginx, and other dependencies. | ||
|
||
################################ Stage: frontend-builder (build frontend assets) | ||
FROM --platform=${BUILDPLATFORM} node:${NODE_VERSION} AS frontend-builder | ||
WORKDIR /label-studio/web | ||
|
||
COPY web . | ||
COPY pyproject.toml ../pyproject.toml | ||
|
||
################################ Stage: venv-builder (prepare the virtualenv) | ||
FROM python:${PYTHON_VERSION}-slim AS venv-builder | ||
ARG POETRY_VERSION | ||
|
||
ENV PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
PIP_NO_CACHE_DIR=off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
PIP_DEFAULT_TIMEOUT=100 \ | ||
PIP_CACHE_DIR="/.cache" \ | ||
POETRY_CACHE_DIR="/.poetry-cache" \ | ||
POETRY_HOME="/opt/poetry" \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=true \ | ||
PATH="/opt/poetry/bin:$PATH" | ||
|
||
ADD https://install.python-poetry.org /tmp/install-poetry.py | ||
RUN python /tmp/install-poetry.py | ||
|
||
RUN --mount=type=cache,target="/var/cache/apt",sharing=locked \ | ||
--mount=type=cache,target="/var/lib/apt/lists",sharing=locked \ | ||
set -eux; \ | ||
apt-get update; \ | ||
apt-get install --no-install-recommends -y \ | ||
build-essential git; \ | ||
apt-get autoremove -y | ||
|
||
WORKDIR /label-studio | ||
|
||
ENV VENV_PATH="/label-studio/.venv" | ||
ENV PATH="$VENV_PATH/bin:$PATH" | ||
|
||
## Starting from this line all packages will be installed in $VENV_PATH | ||
|
||
# Copy dependency files | ||
COPY pyproject.toml poetry.lock README.md ./ | ||
|
||
# Install dependencies without dev packages | ||
RUN --mount=type=cache,target=$POETRY_CACHE_DIR,sharing=locked \ | ||
poetry check --lock && poetry install --no-root --without test --extras uwsgi | ||
|
||
# Install LS | ||
COPY label_studio label_studio | ||
RUN --mount=type=cache,target=$POETRY_CACHE_DIR,sharing=locked \ | ||
# `--extras uwsgi` is mandatory here due to poetry bug: https://github.com/python-poetry/poetry/issues/7302 | ||
poetry install --only-root --extras uwsgi && \ | ||
python3 label_studio/manage.py collectstatic --no-input | ||
|
||
################################ Stage: py-version-generator | ||
FROM venv-builder AS py-version-generator | ||
ARG VERSION_OVERRIDE | ||
ARG BRANCH_OVERRIDE | ||
|
||
# Create version_.py and ls-version_.py | ||
RUN --mount=type=bind,source=.git,target=./.git \ | ||
VERSION_OVERRIDE=${VERSION_OVERRIDE} BRANCH_OVERRIDE=${BRANCH_OVERRIDE} poetry run python label_studio/core/version.py | ||
|
||
################################### Stage: prod | ||
FROM python:${PYTHON_VERSION}-slim AS production | ||
|
||
ENV LS_DIR=/label-studio \ | ||
HOME=/label-studio \ | ||
LABEL_STUDIO_BASE_DATA_DIR=/label-studio/data \ | ||
OPT_DIR=/opt/heartex/instance-data/etc \ | ||
PATH="/label-studio/.venv/bin:$PATH" \ | ||
DJANGO_SETTINGS_MODULE=core.settings.label_studio \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 | ||
|
||
WORKDIR $LS_DIR | ||
|
||
# install prerequisites for app | ||
RUN --mount=type=cache,target="/var/cache/apt",sharing=locked \ | ||
--mount=type=cache,target="/var/lib/apt/lists",sharing=locked \ | ||
set -eux; \ | ||
apt-get update; \ | ||
apt-get upgrade -y; \ | ||
apt-get install --no-install-recommends -y libexpat1 \ | ||
gnupg2 curl; \ | ||
apt-get autoremove -y | ||
|
||
# install nginx | ||
RUN --mount=type=cache,target="/var/cache/apt",sharing=locked \ | ||
--mount=type=cache,target="/var/lib/apt/lists",sharing=locked \ | ||
set -eux; \ | ||
curl -sSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /etc/apt/keyrings/nginx-archive-keyring.gpg >/dev/null; \ | ||
DEBIAN_VERSION=$(awk -F '=' '/^VERSION_CODENAME=/ {print $2}' /etc/os-release); \ | ||
printf "deb [signed-by=/etc/apt/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/debian ${DEBIAN_VERSION} nginx\n" > /etc/apt/sources.list.d/nginx.list; \ | ||
printf "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" > /etc/apt/preferences.d/99nginx; \ | ||
apt-get update; \ | ||
apt-get install --no-install-recommends -y nginx; \ | ||
apt-get autoremove -y | ||
|
||
RUN set -eux; \ | ||
mkdir -p $LS_DIR $LABEL_STUDIO_BASE_DATA_DIR $OPT_DIR && \ | ||
chown -R 1001:0 $LS_DIR $LABEL_STUDIO_BASE_DATA_DIR $OPT_DIR /var/log/nginx /etc/nginx | ||
|
||
COPY --chown=1001:0 deploy/default.conf /etc/nginx/nginx.conf | ||
|
||
# Copy essential files for installing Label Studio and its dependencies | ||
COPY --chown=1001:0 pyproject.toml . | ||
COPY --chown=1001:0 poetry.lock . | ||
COPY --chown=1001:0 README.md . | ||
COPY --chown=1001:0 LICENSE LICENSE | ||
COPY --chown=1001:0 licenses licenses | ||
COPY --chown=1001:0 deploy deploy | ||
|
||
# Copy files from build stages | ||
COPY --chown=1001:0 --from=venv-builder $LS_DIR $LS_DIR | ||
COPY --chown=1001:0 --from=py-version-generator $LS_DIR/label_studio/core/version_.py $LS_DIR/label_studio/core/version_.py | ||
COPY --chown=1001:0 --from=frontend-builder $LS_DIR/web/dist $LS_DIR/web/dist | ||
|
||
USER 1001 | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["./deploy/docker-entrypoint.sh"] | ||
CMD ["label-studio"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"shadcn": "2.1.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "libs/ui/src/tailwind.config.js", | ||
"css": "libs/ui/src/tailwind.css", | ||
"baseColor": "slate", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@humansignal/shad/components", | ||
"ui": "@humansignal/shad/components/ui", | ||
"utils": "@humansignal/shad/utils", | ||
"lib": "@humansignal/shad/lib", | ||
"hooks": "@humansignal/shad/hooks" | ||
}, | ||
"iconLibrary": "lucide" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { StorybookConfig } from "@storybook/react-webpack5"; | ||
|
||
const config: StorybookConfig = { | ||
core: { builder: "@storybook/builder-webpack5" }, | ||
stories: ["../../../libs/**/*.stories.@(js|jsx|ts|tsx|mdx)", "../../../apps/**/*.stories.@(js|jsx|ts|tsx|mdx)"], | ||
addons: ["@storybook/addon-essentials", "@storybook/addon-interactions", "@nx/react/plugins/storybook"], | ||
framework: { | ||
name: "@storybook/react-webpack5", | ||
options: {}, | ||
}, | ||
|
||
webpackFinal: async (config) => { | ||
config.module.rules.push({ | ||
test: /\.(woff|woff2|eot|ttf|otf)$/, | ||
use: [ | ||
{ | ||
loader: "file-loader", | ||
options: { | ||
name: "[name].[ext]", | ||
outputPath: "fonts/", | ||
}, | ||
}, | ||
], | ||
}); | ||
return config; | ||
}, | ||
}; | ||
|
||
export default config; | ||
|
||
// To customize your webpack configuration you can use the webpackFinal field. | ||
// Check https://storybook.js.org/docs/react/builders/webpack#extending-storybooks-webpack-config | ||
// and https://nx.dev/recipes/storybook/custom-builder-configs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@import '../src/tailwind.css'; | ||
@import '../src/tokens/colors'; | ||
@import '../src/tokens/typography'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import "./preview.scss"; | ||
|
||
export const parameters = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { Button } from "../../ui/src/shad/components/ui/button.tsx"; | ||
|
||
const meta: Meta<typeof Button> = { | ||
component: Button, | ||
render: ({ form, ...args }) => { | ||
return <Button {...args}>Hello</Button>; | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Button>; | ||
|
||
export const Primary: Story = { | ||
args: { | ||
variant: "default", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { | ||
Select, | ||
SelectTrigger, | ||
SelectValue, | ||
SelectContent, | ||
SelectLabel, | ||
SelectItem, | ||
SelectGroup, | ||
} from "../../ui/src/shad/components/ui/select.tsx"; | ||
|
||
const meta: Meta<typeof Select> = { | ||
component: Select, | ||
render: ({ form, ...args }) => { | ||
return ( | ||
<Select> | ||
<SelectTrigger className="w-[180px]"> | ||
<SelectValue placeholder="Select a fruit" /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
<SelectGroup> | ||
<SelectLabel>Fruits</SelectLabel> | ||
<SelectItem value="apple">Apple</SelectItem> | ||
<SelectItem value="banana">Banana</SelectItem> | ||
<SelectItem value="blueberry">Blueberry</SelectItem> | ||
<SelectItem value="grapes">Grapes</SelectItem> | ||
<SelectItem value="pineapple">Pineapple</SelectItem> | ||
</SelectGroup> | ||
</SelectContent> | ||
</Select> | ||
); | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Select>; | ||
|
||
export const Primary: Story = { | ||
args: { | ||
value: "Apple", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import '../src/tokens/colors.scss'; | ||
@import '../src/tokens/typography.scss'; | ||
@import '../src/tailwind'; | ||
@import '../src/tokens/colors'; | ||
@import '../src/tokens/typography'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "../../tailwind.config.ts", | ||
"css": "./src/tailwind.css", | ||
"baseColor": "slate", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@humansignal/shad/components", | ||
"utils": "@humansignal/shad/utils" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as React from "react"; | ||
import { Slot } from "@radix-ui/react-slot"; | ||
import { cva, type VariantProps } from "class-variance-authority"; | ||
import { cn } from "@humansignal/shad/utils/utils"; | ||
|
||
const buttonVariants = cva( | ||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", | ||
{ | ||
variants: { | ||
variant: { | ||
default: "bg-primary text-primary-foreground hover:bg-primary/90", | ||
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90", | ||
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground", | ||
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80", | ||
ghost: "hover:bg-accent hover:text-accent-foreground", | ||
link: "text-primary underline-offset-4 hover:underline", | ||
}, | ||
size: { | ||
default: "h-10 px-4 py-2", | ||
sm: "h-9 rounded-md px-3", | ||
lg: "h-11 rounded-md px-8", | ||
icon: "h-10 w-10", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: "default", | ||
size: "default", | ||
}, | ||
}, | ||
); | ||
|
||
export interface ButtonProps | ||
extends React.ButtonHTMLAttributes<HTMLButtonElement>, | ||
VariantProps<typeof buttonVariants> { | ||
asChild?: boolean; | ||
} | ||
|
||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( | ||
({ className, variant, size, asChild = false, ...props }, ref) => { | ||
const Comp = asChild ? Slot : "button"; | ||
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />; | ||
}, | ||
); | ||
Button.displayName = "Button"; | ||
|
||
export { Button, buttonVariants }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like example changes that were committed on accident.