From 94a02ba6d68d55be8b681f03b3006aff34641519 Mon Sep 17 00:00:00 2001
From: Pavel <14926950+prichodko@users.noreply.github.com>
Date: Tue, 14 Feb 2023 17:36:38 +0100
Subject: [PATCH] Add more components, message actions & reactions (#339)
* hide sidebar on small screen
* add reply component
* add radix dependencies
* add dropdown menu component
* add popover component
* add tooltip component
* add react button component
* add reaction popover
* update chat message actions
* add basic dialog and sheet components
* add ref to Button component
* add chat message reactions
* add reply and reactions to chat message
* remove console.log
* add dropdown menu to topbar
* add ref and support aria in IconButton
* yarn.lock
* add stylesheet reset to storybook
* add pinned state to message
* remove extraneous component
* add all button variants
* fix button icons
* use IconButton in actions
* remove erroneous character
* add reply to composer + simplify
* use correct button in reply
---
apps/vite/src/app.tsx | 9 +-
apps/vite/styles/app.css | 18 ++
packages/components/.storybook/preview.tsx | 2 +
packages/components/.storybook/reset.css | 100 ++++++++
packages/components/package.json | 3 +
.../components/src/button/button.stories.tsx | 64 ++++-
packages/components/src/button/button.tsx | 100 ++++++--
packages/components/src/button/index.tsx | 2 +-
packages/components/src/composer/composer.tsx | 59 +++--
.../components/src/dialog/dialog.stories.tsx | 32 +++
packages/components/src/dialog/dialog.tsx | 116 +++++++++
packages/components/src/dialog/index.tsx | 1 +
.../dropdown-menu/dropdown-menu.stories.tsx | 85 +++++++
.../src/dropdown-menu/dropdown-menu.tsx | 108 +++++++++
.../components/src/dropdown-menu/index.tsx | 1 +
.../src/icon-button/icon-button.tsx | 29 +--
packages/components/src/input/input.tsx | 2 +-
.../components/src/messages/chat-message.tsx | 89 -------
.../messages/components/actions.stories.tsx | 10 +
.../src/messages/components/actions.tsx | 118 ++++++++-
.../messages/components/reaction-popover.tsx | 64 +++++
.../messages/components/reactions.stories.tsx | 10 +
.../src/messages/components/reactions.tsx | 175 +++++++-------
packages/components/src/messages/index.tsx | 76 ++++--
...ssages.stories.tsx => message.stories.tsx} | 47 +++-
packages/components/src/messages/message.tsx | 127 ++++++++++
packages/components/src/messages/types.ts | 12 +
packages/components/src/popover/index.tsx | 1 +
.../src/popover/popover.stories.tsx | 32 +++
packages/components/src/popover/popover.tsx | 51 ++++
.../components/src/react-button/index.tsx | 1 +
.../src/react-button/react-button.stories.tsx | 67 ++++++
.../src/react-button/react-button.tsx | 141 +++++++++++
packages/components/src/reply/index.tsx | 1 +
.../components/src/reply/reply.stories.tsx | 84 +++++++
packages/components/src/reply/reply.tsx | 97 ++++++++
packages/components/src/sheet/index.tsx | 1 +
.../components/src/sheet/sheet.stories.tsx | 32 +++
packages/components/src/sheet/sheet.tsx | 79 ++++++
packages/components/src/tooltip/index.tsx | 1 +
.../components/src/tooltip/tooltip.native.tsx | 3 +
.../src/tooltip/tooltip.stories.tsx | 30 +++
packages/components/src/tooltip/tooltip.tsx | 83 +++++++
packages/components/src/topbar/topbar.tsx | 49 +++-
packages/icons/vite.config.ts | 1 -
yarn.lock | 224 +++++++++++++++++-
46 files changed, 2134 insertions(+), 303 deletions(-)
create mode 100644 packages/components/.storybook/reset.css
create mode 100644 packages/components/src/dialog/dialog.stories.tsx
create mode 100644 packages/components/src/dialog/dialog.tsx
create mode 100644 packages/components/src/dialog/index.tsx
create mode 100644 packages/components/src/dropdown-menu/dropdown-menu.stories.tsx
create mode 100644 packages/components/src/dropdown-menu/dropdown-menu.tsx
create mode 100644 packages/components/src/dropdown-menu/index.tsx
delete mode 100644 packages/components/src/messages/chat-message.tsx
create mode 100644 packages/components/src/messages/components/reaction-popover.tsx
rename packages/components/src/messages/{messages.stories.tsx => message.stories.tsx} (74%)
create mode 100644 packages/components/src/messages/message.tsx
create mode 100644 packages/components/src/messages/types.ts
create mode 100644 packages/components/src/popover/index.tsx
create mode 100644 packages/components/src/popover/popover.stories.tsx
create mode 100644 packages/components/src/popover/popover.tsx
create mode 100644 packages/components/src/react-button/index.tsx
create mode 100644 packages/components/src/react-button/react-button.stories.tsx
create mode 100644 packages/components/src/react-button/react-button.tsx
create mode 100644 packages/components/src/reply/index.tsx
create mode 100644 packages/components/src/reply/reply.stories.tsx
create mode 100644 packages/components/src/reply/reply.tsx
create mode 100644 packages/components/src/sheet/index.tsx
create mode 100644 packages/components/src/sheet/sheet.stories.tsx
create mode 100644 packages/components/src/sheet/sheet.tsx
create mode 100644 packages/components/src/tooltip/index.tsx
create mode 100644 packages/components/src/tooltip/tooltip.native.tsx
create mode 100644 packages/components/src/tooltip/tooltip.stories.tsx
create mode 100644 packages/components/src/tooltip/tooltip.tsx
diff --git a/apps/vite/src/app.tsx b/apps/vite/src/app.tsx
index b6d560f8..44b332bb 100644
--- a/apps/vite/src/app.tsx
+++ b/apps/vite/src/app.tsx
@@ -88,12 +88,9 @@ function App() {
-
+
+
+
{showMembers && (
diff --git a/apps/vite/styles/app.css b/apps/vite/styles/app.css
index ab34016c..3bcc1fd1 100644
--- a/apps/vite/styles/app.css
+++ b/apps/vite/styles/app.css
@@ -17,6 +17,7 @@ body,
}
#main {
+ position: relative;
display: grid;
grid-template-rows: 56px 1fr 100px;
height: 100vh;
@@ -45,7 +46,24 @@ body,
margin-top: -56px;
}
+#composer {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ right: 0;
+}
+
#members {
width: 352px;
overflow: auto;
}
+
+@media screen and (max-width: 768px) {
+ #app {
+ grid-template-columns: 1fr;
+ }
+
+ #sidebar {
+ display: none;
+ }
+}
diff --git a/packages/components/.storybook/preview.tsx b/packages/components/.storybook/preview.tsx
index a0134e88..7056e3e4 100644
--- a/packages/components/.storybook/preview.tsx
+++ b/packages/components/.storybook/preview.tsx
@@ -3,6 +3,8 @@ import { TamaguiProvider } from '@tamagui/core'
import { config } from '../src'
import { Parameters, Decorator } from '@storybook/react'
+import './reset.css'
+
export const parameters: Parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
diff --git a/packages/components/.storybook/reset.css b/packages/components/.storybook/reset.css
new file mode 100644
index 00000000..c793f03b
--- /dev/null
+++ b/packages/components/.storybook/reset.css
@@ -0,0 +1,100 @@
+/*
+ 1. Use a more-intuitive box-sizing model.
+*/
+*,
+*::before,
+*::after {
+ box-sizing: border-box;
+}
+
+:root {
+ font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
+ font-size: 16px;
+ line-height: 24px;
+ font-weight: 400;
+
+ color-scheme: light dark;
+ color: rgba(255, 255, 255, 0.87);
+ background-color: #fff;
+
+ font-synthesis: none;
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ -webkit-text-size-adjust: 100%;
+}
+
+/*
+ 2. Remove default margin
+*/
+* {
+ margin: 0;
+}
+
+/*
+ 3. Allow percentage-based heights in the application
+*/
+html,
+body {
+ height: 100vh;
+ width: 100vw;
+ overflow: hidden;
+ overscroll-behavior-y: none; /* not working on Safari */
+}
+/*
+ Typographic tweaks!
+ 4. Add accessible line-height
+ 5. Improve text rendering
+*/
+body {
+ line-height: 1.5;
+ -webkit-font-smoothing: antialiased;
+ padding: 0;
+ -webkit-overflow-scrolling: touch;
+}
+/*
+ 6. Improve media defaults
+*/
+img,
+picture,
+video,
+canvas,
+svg {
+ display: block;
+ max-width: 100%;
+}
+/*
+ 7. Remove built-in form typography styles
+*/
+input,
+button,
+textarea,
+select {
+ font: inherit;
+}
+/*
+ 8. Avoid text overflows
+*/
+p,
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+ overflow-wrap: break-word;
+}
+/*
+ 9. Create a root stacking context
+*/
+#root,
+#__next {
+ isolation: isolate;
+}
+
+/*
+ 10. Remove user selection on buttons
+*/
+button {
+ user-select: none;
+}
diff --git a/packages/components/package.json b/packages/components/package.json
index b1c25268..7745ce0e 100644
--- a/packages/components/package.json
+++ b/packages/components/package.json
@@ -22,6 +22,9 @@
"react-native-web": "^0.18.0"
},
"dependencies": {
+ "@radix-ui/react-dropdown-menu": "^2.0.2",
+ "@radix-ui/react-popover": "^1.0.3",
+ "@radix-ui/react-tooltip": "^1.0.3",
"@status-im/icons": "*",
"@tamagui/animations-css": "1.0.15",
"@tamagui/animations-react-native": "1.0.15",
diff --git a/packages/components/src/button/button.stories.tsx b/packages/components/src/button/button.stories.tsx
index 3f7d115c..91b93de8 100644
--- a/packages/components/src/button/button.stories.tsx
+++ b/packages/components/src/button/button.stories.tsx
@@ -1,3 +1,6 @@
+import { action } from '@storybook/addon-actions'
+import { Stack } from 'tamagui'
+
import { Button } from './button'
import type { Meta, StoryObj } from '@storybook/react'
@@ -5,18 +8,25 @@ import type { Meta, StoryObj } from '@storybook/react'
// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
const meta: Meta = {
component: Button,
- argTypes: {},
+ args: {
+ onPress: action('press'),
+ },
+ argTypes: {
+ disabled: {
+ defaultValue: false,
+ },
+ },
+ decorators: [
+ Story => (
+
+
+
+ ),
+ ],
}
type Story = StoryObj
-// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args
-export const Primary: Story = {
- args: {
- children: 'Click me',
- },
-}
-
const icon = (