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

refactor: use tailwind components for core css classes in components #468

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
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
48 changes: 48 additions & 0 deletions .changeset/major-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
'@cypress-design/component-tailwind-plugins': major
'@cypress-design/constants-docmenu': major
'@cypress-design/react-docmenu': major
'@cypress-design/vue-docmenu': major
'@cypress-design/css': major
'@cypress-design/constants-accordion': major
'@cypress-design/react-accordion': major
'@cypress-design/vue-accordion': major
'@cypress-design/constants-alert': major
'@cypress-design/react-alert': major
'@cypress-design/vue-alert': major
'@cypress-design/constants-button': major
'@cypress-design/react-button': major
'@cypress-design/vue-button': major
'@cypress-design/constants-checkbox': major
'@cypress-design/react-checkbox': major
'@cypress-design/vue-checkbox': major
'@cypress-design/react-icon': major
'@cypress-design/vue-icon': major
'@cypress-design/react-logo': major
'@cypress-design/vue-logo': major
'@cypress-design/constants-menu': major
'@cypress-design/react-menu': major
'@cypress-design/vue-menu': major
'@cypress-design/constants-modal': major
'@cypress-design/react-modal': major
'@cypress-design/vue-modal': major
'@cypress-design/constants-spinner': major
'@cypress-design/react-spinner': major
'@cypress-design/vue-spinner': major
'@cypress-design/constants-statusicon': major
'@cypress-design/react-statusicon': major
'@cypress-design/vue-statusicon': major
'@cypress-design/constants-tabs': major
'@cypress-design/react-tabs': major
'@cypress-design/vue-tabs': major
'@cypress-design/constants-tag': major
'@cypress-design/react-tag': major
'@cypress-design/vue-tag': major
'@cypress-design/constants-testresult': major
'@cypress-design/react-testresult': major
'@cypress-design/vue-testresult': major
'@cypress-design/react-tooltip': major
'@cypress-design/vue-tooltip': major
---

refactor: use tailwind components to manage specificity of styles
2 changes: 1 addition & 1 deletion components/Accordion/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"build:types": "tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-accordion": "*",
"@cypress-design/details-animation": "*",
"@cypress-design/react-icon": "*",
"clsx": "*"
},
"devDependencies": {
"@cypress-design/constants-accordion": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion components/Accordion/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
},
"license": "MIT",
"dependencies": {
"@cypress-design/constants-accordion": "*",
"@cypress-design/details-animation": "*",
"@cypress-design/vue-icon": "*"
},
"devDependencies": {
"@cypress-design/constants-accordion": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*"
}
}
2 changes: 1 addition & 1 deletion components/Alert/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"build:types": "tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-alert": "*",
"@cypress-design/details-animation": "*",
"@cypress-design/react-icon": "*",
"clsx": "*"
},
"devDependencies": {
"@cypress-design/constants-alert": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*",
"postcss": "^8.4.38",
"rollup-plugin-postcss": "^4.0.2",
Expand Down
2 changes: 1 addition & 1 deletion components/Alert/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"build:types": "yarn vue-tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-alert": "*",
"@cypress-design/details-animation": "*",
"@cypress-design/vue-icon": "*"
},
"devDependencies": {
"@cypress-design/constants-alert": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion components/Button/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"build:types": "tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-button": "*",
"clsx": "*"
},
"devDependencies": {
"@cypress-design/constants-button": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*"
},
"license": "MIT"
Expand Down
4 changes: 3 additions & 1 deletion components/Button/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
"build:module": "yarn vite build",
"build:types": "yarn vue-tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-button": "*"
},
"devDependencies": {
"@cypress-design/constants-button": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion components/Checkbox/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"build:types": "tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-checkbox": "*",
"@cypress-design/react-icon": "*",
"clsx": "*"
},
"devDependencies": {
"@cypress-design/constants-checkbox": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion components/Checkbox/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"build:types": "yarn vue-tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-checkbox": "*",
"@cypress-design/vue-icon": "*"
},
"devDependencies": {
"@cypress-design/constants-checkbox": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*"
},
"license": "MIT"
Expand Down
14 changes: 9 additions & 5 deletions components/DocMenu/assertions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/// <reference types="cypress" />

import type { NavGroup, NavItemLink } from './constants'
import { colors } from '@cypress-design/css/dist/colors'
import hexRgb from 'hex-rgb'

const { red, green, blue } = hexRgb(colors.indigo[500])
const indigoToCompare = `rgb(${red}, ${green}, ${blue})`

const menuItems = [
{
Expand Down Expand Up @@ -119,17 +124,16 @@ export default function assertions(
it('expands a section where an element is activated', () => {
mountCustomLinkStory()
cy.findByText('Foo', { selector: 'button' }).should(
'have.class',
'text-indigo-500',
'have.css',
'color',
indigoToCompare,
)

cy.findByText('Set path to /kephren', { selector: 'button' }).click()

cy.findByText('Kephren', { selector: 'button' })
.should('be.visible')
.should('have.class', 'text-indigo-500')

cy.findByTestId('doc-menu-active-marker').should('have.css', 'top', '220px')
.should('have.css', 'color', indigoToCompare)
})
}

Expand Down
11 changes: 11 additions & 0 deletions components/DocMenu/constants/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,14 @@ export const CssClasses = {
openListBorderLeft:
'absolute left-[8px] top-0 w-[1px] h-full bg-gray-100 dark:bg-gray-900',
} as const

export const CssLink = {
wrapper: 'list-none p-0 scroll-my-10',
static: 'group relative block w-full pl-[24px]',
active: 'text-indigo-500 dark:text-indigo-400',
inactive: 'text-gray-700 dark:text-gray-500',
negativeDepth: 'py-[8px] text-[16px] leading-[24px]',
positiveDepth: 'leading-[20px] text-[14px] py-[12px]',
markerStatic:
'left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full',
} as const
28 changes: 12 additions & 16 deletions components/DocMenu/react/_DocLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import clsx from 'clsx'
import { NavItemLink } from '@cypress-design/constants-docmenu'
import { type NavItemLink, CssLink } from '@cypress-design/constants-docmenu'

export interface Context {
setMarkerIsMoving: (markerIsMoving: boolean) => void
Expand Down Expand Up @@ -86,30 +86,26 @@ export const DocLink = React.forwardRef<DocLinkForward, DocLinkProps>(
}))

return (
<li ref={activeLIRef} className="list-none p-0 scroll-my-10">
<li ref={activeLIRef} className={CssLink.wrapper}>
<LinkComponent
{...itemRest}
className={clsx('group relative block w-full pl-[24px]', {
'text-indigo-500 dark:text-indigo-400': active,
'text-gray-700 dark:text-gray-500': !active,
'py-[8px] text-[16px] leading-[24px]': depth < 0,
'leading-[20px] text-[14px] py-[12px]': depth >= 0,
className={clsx(CssLink.static, {
[CssLink.active]: active,
[CssLink.inactive]: !active,
[CssLink.negativeDepth]: depth < 0,
[CssLink.positiveDepth]: depth >= 0,
})}
style={{
paddingLeft: depth >= 0 ? `${depth * 12 + 48}px` : undefined,
}}
>
{depth >= 0 ? (
<div
className={clsx(
'left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full',
{
hidden: !markerIsMoving || !active,
'group-hover:block bg-gray-300':
!active && context.collapsible,
'bg-indigo-500 dark:bg-indigo-400': active && markerIsMoving,
},
)}
className={clsx(CssLink.markerStatic, {
hidden: !markerIsMoving || !active,
'group-hover:block bg-gray-300': !active && context.collapsible,
'bg-indigo-500 dark:bg-indigo-400': active && markerIsMoving,
})}
/>
) : null}
{item.label}
Expand Down
2 changes: 1 addition & 1 deletion components/DocMenu/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"build:types": "tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-docmenu": "*",
"@cypress-design/react-icon": "*",
"clsx": "*"
},
"devDependencies": {
"@cypress-design/constants-docmenu": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*"
},
"license": "MIT"
Expand Down
34 changes: 19 additions & 15 deletions components/DocMenu/vue/_DocLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
nextTick,
computed,
} from 'vue'
import type { NavItemLink } from '@cypress-design/constants-docmenu'
import { type NavItemLink, CssLink } from '@cypress-design/constants-docmenu'

const props = withDefaults(
defineProps<{
Expand Down Expand Up @@ -102,29 +102,33 @@ const itemWithoutLabel = computed(() => {
</script>

<template>
<li ref="$container" class="list-none p-0 scroll-my-10">
<li ref="$container" :class="CssLink.wrapper">
<component
:is="linkComponent"
v-bind="itemWithoutLabel"
class="group relative block w-full pl-[24px]"
:class="{
'text-indigo-500 dark:text-indigo-400': active,
'text-gray-700 dark:text-gray-500': !active,
'py-[8px] text-[16px] leading-[24px]': depth < 0,
'leading-[20px] text-[14px] py-[12px]': depth >= 0,
}"
:class="[
CssLink.static,
{
[CssLink.active]: active,
[CssLink.inactive]: !active,
[CssLink.negativeDepth]: depth < 0,
[CssLink.positiveDepth]: depth >= 0,
},
]"
:style="{
paddingLeft: depth >= 0 ? `${depth * 12 + 48}px` : undefined,
}"
>
<div
v-if="depth >= 0"
class="left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full"
:class="{
hidden: !markerIsMoving || !active,
'group-hover:block bg-gray-300': !active && collapsible,
'bg-indigo-500': active && markerIsMoving,
}"
:class="[
CssLink.markerStatic,
{
hidden: !markerIsMoving || !active,
'group-hover:block bg-gray-300': !active && collapsible,
'bg-indigo-500': active && markerIsMoving,
},
]"
/>
{{ item.label }}
</component>
Expand Down
2 changes: 1 addition & 1 deletion components/DocMenu/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"build:types": "yarn vue-tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-docmenu": "*",
"@cypress-design/vue-icon": "*"
},
"devDependencies": {
"@cypress-design/constants-docmenu": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion components/Menu/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"build:types": "tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-menu": "*",
"clsx": "*"
},
"devDependencies": {
"@cypress-design/constants-menu": "*",
"@cypress-design/react-icon": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*"
},
Expand Down
4 changes: 3 additions & 1 deletion components/Menu/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
"build:module": "yarn vite build",
"build:types": "yarn vue-tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-menu": "*"
},
"devDependencies": {
"@cypress-design/constants-menu": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*",
"@cypress-design/vue-icon": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion components/Modal/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
"build:types": "tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-modal": "*",
"@cypress-design/react-icon": "*",
"clsx": "*"
},
"devDependencies": {
"@cypress-design/constants-modal": "*",
"@cypress-design/css": "*"
},
"license": "MIT"
Expand Down
4 changes: 3 additions & 1 deletion components/Modal/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
"build:module": "yarn vite build",
"build:types": "yarn vue-tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-modal": "*"
},
"devDependencies": {
"@cypress-design/constants-modal": "*",
"@cypress-design/vue-icon": "*"
},
"license": "MIT"
Expand Down
4 changes: 3 additions & 1 deletion components/Spinner/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
"build:module": "rollup -c ./rollup.config.mjs",
"build:types": "tsc --project ./tsconfig.build.json"
},
"dependencies": {
"@cypress-design/constants-spinner": "*"
},
"devDependencies": {
"@cypress-design/constants-spinner": "*",
"@cypress-design/rollup-plugin-tailwind-keep": "*",
"postcss": "^8.4.38",
"rollup-plugin-postcss": "^4.0.2",
Expand Down
Loading
Loading