File size: 7,996 Bytes
436a8e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d98aff
 
 
d9a380f
436a8e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27eab59
436a8e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
import { motion } from 'framer-motion';
import * as Tooltip from '@radix-ui/react-tooltip';
import { classNames } from '~/utils/classNames';
import type { TabVisibilityConfig } from '~/components/settings/settings.types';
import { TAB_LABELS } from '~/components/settings/settings.types';

const TAB_ICONS = {
  profile: 'i-ph:user',
  settings: 'i-ph:gear',
  notifications: 'i-ph:bell',
  features: 'i-ph:star',
  data: 'i-ph:database',
  providers: 'i-ph:plug',
  connection: 'i-ph:wifi-high',
  debug: 'i-ph:bug',
  'event-logs': 'i-ph:list-bullets',
  update: 'i-ph:arrow-clockwise',
  'task-manager': 'i-ph:activity',
  'cloud-providers': 'i-ph:cloud',
  'local-providers': 'i-ph:desktop',
  'service-status': 'i-ph:activity-bold',
};

interface TabTileProps {
  tab: TabVisibilityConfig;
  onClick: () => void;
  isActive?: boolean;
  hasUpdate?: boolean;
  statusMessage?: string;
  description?: string;
  isLoading?: boolean;
}

export const TabTile = ({
  tab,
  onClick,
  isActive = false,
  hasUpdate = false,
  statusMessage,
  description,
  isLoading = false,
}: TabTileProps) => {
  return (
    <Tooltip.Provider delayDuration={200}>
      <Tooltip.Root>
        <Tooltip.Trigger asChild>
          <motion.button
            onClick={onClick}
            disabled={isLoading}
            className={classNames(
              'relative flex flex-col items-center justify-center gap-3 p-6 rounded-xl',
              'w-full h-full min-h-[160px]',

              // Background and border styles
              'bg-white dark:bg-[#141414]',
              'border border-[#E5E5E5]/50 dark:border-[#333333]/50',

              // Shadow and glass effect
              'shadow-sm',
              'dark:shadow-[0_0_15px_rgba(0,0,0,0.1)]',
              'dark:bg-opacity-50',

              // Hover effects
              'hover:border-purple-500/30 dark:hover:border-purple-500/30',
              'hover:bg-gradient-to-br hover:from-purple-50/50 hover:to-white dark:hover:from-purple-500/5 dark:hover:to-[#141414]',
              'hover:shadow-md hover:shadow-purple-500/5',
              'dark:hover:shadow-purple-500/10',

              // Focus states for keyboard navigation
              'focus:outline-none',
              'focus:ring-2 focus:ring-purple-500/50 focus:ring-offset-2',
              'dark:focus:ring-offset-[#141414]',
              'focus:border-purple-500/30',

              // Active state
              isActive
                ? [
                    'border-purple-500/50 dark:border-purple-500/50',
                    'bg-gradient-to-br from-purple-50 to-white dark:from-purple-500/10 dark:to-[#141414]',
                    'shadow-md shadow-purple-500/10',
                  ]
                : '',

              // Loading state
              isLoading ? 'cursor-wait opacity-70' : '',

              // Transitions
              'transition-all duration-300 ease-out',
              'group',
            )}
            whileHover={
              !isLoading
                ? {
                    scale: 1.02,
                    transition: { duration: 0.2, ease: 'easeOut' },
                  }
                : {}
            }
            whileTap={
              !isLoading
                ? {
                    scale: 0.98,
                    transition: { duration: 0.1, ease: 'easeIn' },
                  }
                : {}
            }
          >
            {/* Loading Overlay */}
            {isLoading && (
              <motion.div
                className={classNames(
                  'absolute inset-0 rounded-xl z-10',
                  'bg-white/50 dark:bg-black/50',
                  'backdrop-blur-sm',
                  'flex items-center justify-center',
                )}
                initial={{ opacity: 0 }}
                animate={{ opacity: 1 }}
                transition={{ duration: 0.2 }}
              >
                <motion.div
                  className={classNames('w-8 h-8 rounded-full', 'border-2 border-purple-500/30', 'border-t-purple-500')}
                  animate={{ rotate: 360 }}
                  transition={{
                    duration: 1,
                    repeat: Infinity,
                    ease: 'linear',
                  }}
                />
              </motion.div>
            )}

            {/* Status Indicator */}
            {hasUpdate && (
              <motion.div
                className={classNames(
                  'absolute top-3 right-3',
                  'w-2.5 h-2.5 rounded-full',
                  'bg-green-500',
                  'shadow-lg shadow-green-500/20',
                  'ring-4 ring-green-500/20',
                )}
                initial={{ scale: 0 }}
                animate={{ scale: 1 }}
                transition={{ type: 'spring', bounce: 0.5 }}
              />
            )}

            {/* Background glow effect */}
            <div
              className={classNames(
                'absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100',
                'bg-gradient-to-br from-purple-500/5 to-transparent dark:from-purple-500/10',
                'transition-opacity duration-300',
                isActive ? 'opacity-100' : '',
              )}
            />

            {/* Icon */}
            <div
              className={classNames(
                TAB_ICONS[tab.id],
                'w-12 h-12',
                'relative',
                'text-gray-600 dark:text-gray-300',
                'group-hover:text-purple-500 dark:group-hover:text-purple-400',
                'transition-all duration-300',
                isActive ? 'text-purple-500 dark:text-purple-400 scale-110' : '',
              )}
            />

            {/* Label and Description */}
            <div className="relative flex flex-col items-center text-center">
              <div
                className={classNames(
                  'text-base font-medium',
                  'text-gray-700 dark:text-gray-200',
                  'group-hover:text-purple-500 dark:group-hover:text-purple-400',
                  'transition-colors duration-300',
                  isActive ? 'text-purple-500 dark:text-purple-400' : '',
                )}
              >
                {TAB_LABELS[tab.id]}
              </div>
              {description && (
                <div
                  className={classNames(
                    'text-xs mt-1',
                    'text-gray-500 dark:text-gray-400',
                    'group-hover:text-purple-400/70 dark:group-hover:text-purple-300/70',
                    'transition-colors duration-300',
                    'max-w-[180px]',
                    isActive ? 'text-purple-400/70 dark:text-purple-300/70' : '',
                  )}
                >
                  {description}
                </div>
              )}
            </div>

            {/* Bottom indicator line */}
            <div
              className={classNames(
                'absolute bottom-0 left-1/2 -translate-x-1/2',
                'w-12 h-0.5 rounded-full',
                'bg-purple-500/0 group-hover:bg-purple-500/50',
                'transition-all duration-300 ease-out',
                'transform scale-x-0 group-hover:scale-x-100',
                isActive ? 'bg-purple-500 scale-x-100' : '',
              )}
            />
          </motion.button>
        </Tooltip.Trigger>
        <Tooltip.Portal>
          <Tooltip.Content
            className={classNames(
              'px-3 py-1.5 rounded-lg',
              'bg-[#18181B] text-white',
              'text-sm font-medium',
              'shadow-xl',
              'select-none',
              'z-[100]',
            )}
            side="top"
            sideOffset={5}
          >
            {statusMessage || TAB_LABELS[tab.id]}
            <Tooltip.Arrow className="fill-[#18181B]" />
          </Tooltip.Content>
        </Tooltip.Portal>
      </Tooltip.Root>
    </Tooltip.Provider>
  );
};