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

Tec 4141 front resumo componentes de subtotais ds #24

Merged

Conversation

juninhokaponne
Copy link
Contributor

@juninhokaponne juninhokaponne commented Mar 21, 2024

Task link

(required)

Jira task

Layout link

(optional)

Web version

Mobile version

Task description

Create the Subtotals component in the Design System. Note that if there are no discounts applied, the discount area should be hidden, and the total amount should be adjusted accordingly. Once created, integrate the Subtotals component with Tempranillo.

Roadmap

(optional)
Step by step about what you did in this PR

  • Create all components on the design system
  • Create and follow the Figma guide for development
  • Create a responsive component for smaller screens according to Figma.

Screenshots

(required when is related to design and/or layout)
Add here images from browsers that tempranillo is more used (Chrome/Safari/Firefox)

Web version:

image

Mobile Version:

image

Unrelated Issues

(optional)

How to test

(optional)

To test, simply open the Chardonay project, run the project locally and look for the PurchaseSummary component.

Ambient to test

(required)
Enviroment

Summary by CodeRabbit

  • Novos Recursos

    • Adicionado um componente Resumo de Compra que exibe um sumário dos itens comprados, incluindo preços dos produtos, custos de entrega e preço total com detalhes de pagamento parcelado opcional.
    • Introduzido um novo componente Acordeão do Resumo de Compra que permite aos usuários alternar a visibilidade de uma lista de descontos em um estilo de acordeão.
  • Estilo

    • Implementados estilos para a seção de resumo de compra e para o componente de acordeão, incluindo containers para itens, preços, totais e detalhes de pagamento.
  • Documentação

    • Adicionadas histórias para o componente Resumo de Compra no Storybook, permitindo visualizar diferentes configurações de propriedades.

Copy link

coderabbitai bot commented Mar 21, 2024

Walkthrough

Uma atualização substancial foi realizada no componente PurchaseSummary, introduzindo uma exibição detalhada e interativa dos resumos de compra, incluindo preços dos produtos, custos de entrega, e o total, com detalhes opcionais de pagamento parcelado. Adicionalmente, um novo componente PurchaseSummaryAccordion foi criado para exibir detalhes de descontos de forma expansível.

Changes

Arquivos Resumo das Alterações
src/components/PurchaseSummary/index.tsx
.../style.tsx
Adiciona o componente PurchaseSummary e estilos para sumarizar itens comprados, custos e totais.
.../PurchaseSummary/PurchaseSummary.stories.tsx Introduz histórias para PurchaseSummary com diferentes configurações de props para testes visuais.
.../PurchaseSummaryAccordion/index.tsx
.../style.tsx
.../type.ts
Cria o componente PurchaseSummaryAccordion e respectivos estilos e tipos para exibição de descontos.

🐰✨
No reino digital, um coelho a pular,
Com códigos e estilos a modificar.
Entre linhas e mais linhas a tecer,
Surge um resumo, para o usuário entender.
Descontos escondidos, agora a revelar,
Com um clique, toda a magia a desdobrar.
🌟📜🐾


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e44c36a and 7ccbe56.
Files ignored due to path filters (1)
  • package.json is excluded by: !**/*.json
Files selected for processing (8)
  • src/components/PurchaseSummary/PurchaseSummary.stories.tsx (1 hunks)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/index.tsx (1 hunks)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/style.tsx (1 hunks)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/type.ts (1 hunks)
  • src/components/PurchaseSummary/index.tsx (1 hunks)
  • src/components/PurchaseSummary/style.tsx (1 hunks)
  • src/components/PurchaseSummary/type.ts (1 hunks)
  • src/tokens/colors.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/components/PurchaseSummary/type.ts
Additional comments: 11
src/components/PurchaseSummary/PurchaseSummaryAccordion/type.ts (1)
  • 3-7: LGTM! A definição da interface PurchaseSummaryAccordionProps está clara e bem tipada, utilizando a reutilização de tipos de forma eficaz.
src/components/PurchaseSummary/PurchaseSummaryAccordion/index.tsx (2)
  • 1-2: As importações dos ícones ChevronDown e ChevronUp, assim como a definição e manipulação do estado isOpen, estão corretas e seguem as boas práticas para componentes de acordeão.

Also applies to: 16-20

  • 36-47: A renderização condicional e o mapeamento da lista listDiscount estão bem implementados, utilizando boas práticas como a verificação da presença de itens na lista e a atribuição de chaves únicas para cada item renderizado.
src/components/PurchaseSummary/PurchaseSummaryAccordion/style.tsx (2)
  • 4-9: Os estilos definidos para AccordionContainer estão apropriados e seguem as boas práticas para a estilização de um contêiner de acordeão.
  • 11-75: A utilização de tokens de cores e a definição de estilos responsivos estão bem implementadas, seguindo as boas práticas para manter a consistência do design e garantir uma boa experiência do usuário em diferentes tamanhos de tela.
src/components/PurchaseSummary/PurchaseSummary.stories.tsx (2)
  • 5-42: A configuração das histórias para o Storybook, incluindo a definição de argTypes, está correta e bem estruturada, permitindo a personalização e teste eficaz dos props do componente PurchaseSummary.
  • 46-87: Os exemplos de histórias EmptyDiscounts e Default estão bem construídos, demonstrando eficazmente o comportamento do componente PurchaseSummary em cenários com e sem descontos. A passagem de props e os valores utilizados são apropriados.
src/components/PurchaseSummary/index.tsx (2)
  • 36-38: A função formatPrice está corretamente implementada, utilizando boas práticas para a formatação de valores monetários no formato brasileiro.
  • 62-70: A integração com o componente PurchaseSummaryAccordion e a renderização condicional dos descontos estão bem implementadas, seguindo boas práticas para uma experiência de usuário aprimorada.
src/tokens/colors.ts (1)
  • 72-72: A adição da cor neutral600 ao grupo de cores neutras do tema escuro está correta, seguindo a convenção de nomenclatura e melhorando a paleta de cores disponível.
src/components/PurchaseSummary/style.tsx (1)
  • 1-119: A utilização de tokens de cores e a definição de estilos responsivos no arquivo style.tsx do componente PurchaseSummary estão bem implementadas, seguindo as boas práticas para manter a consistência do design e garantir uma boa experiência do usuário em diferentes tamanhos de tela.

src/components/PurchaseSummary/index.tsx Outdated Show resolved Hide resolved
src/components/PurchaseSummary/index.tsx Outdated Show resolved Hide resolved
src/components/PurchaseSummary/type.ts Outdated Show resolved Hide resolved
src/components/PurchaseSummary/type.ts Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7ccbe56 and 9b2fe88.
Files selected for processing (7)
  • src/components/PurchaseSummary/PurchaseSummary.stories.tsx (1 hunks)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/index.tsx (1 hunks)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/style.tsx (1 hunks)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/type.ts (1 hunks)
  • src/components/PurchaseSummary/index.tsx (1 hunks)
  • src/components/PurchaseSummary/style.tsx (1 hunks)
  • src/components/PurchaseSummary/type.ts (1 hunks)
Files skipped from review as they are similar to previous changes (7)
  • src/components/PurchaseSummary/PurchaseSummary.stories.tsx
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/index.tsx
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/style.tsx
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/type.ts
  • src/components/PurchaseSummary/index.tsx
  • src/components/PurchaseSummary/style.tsx
  • src/components/PurchaseSummary/type.ts

import styled from 'styled-components'
import { Colors, mediaQueries } from '../../../tokens'

export const AccordionContainer = styled.div`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All styled components come with the Styled suffix. (AccordionContainerStyled, AccordionHeaderStyled, AccordionContentStyled...)
This way it is easier to differentiate common components from styled components.

.itemValue {
color: ${Colors.light.action.action100};
}
`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always use the export pattern at the end of the file.
export { AccordionHeaderStyled, AccordionContentStyled, ... }

@@ -0,0 +1,119 @@
import styled from 'styled-components'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some lint errors in this file.
You need to adjust the pattern of styled component names too.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9b2fe88 and 247d210.
Files selected for processing (2)
  • src/components/PurchaseSummary/index.tsx (1 hunks)
  • src/components/PurchaseSummary/style.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/components/PurchaseSummary/index.tsx
  • src/components/PurchaseSummary/style.tsx

@@ -0,0 +1,89 @@
import { Meta, StoryObj } from '@storybook/react'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index.stories.tsx


type Story = StoryObj<PurchaseSummaryProps>

export const EmptyDiscounts: Story = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is used when displaying stories. It would be interesting to use WithDiscounts and WithoutDiscounts discounts. (or something similar)
This will be displayed as: With Discouts, Without Discouts.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 247d210 and da04e91.
Files selected for processing (6)
  • src/components/PurchaseSummary/PurchaseSummary.stories.tsx (1 hunks)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/index.tsx (1 hunks)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/style.tsx (1 hunks)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/type.ts (1 hunks)
  • src/components/PurchaseSummary/index.tsx (1 hunks)
  • src/components/PurchaseSummary/type.ts (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • src/components/PurchaseSummary/PurchaseSummary.stories.tsx
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/index.tsx
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/style.tsx
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/type.ts
  • src/components/PurchaseSummary/index.tsx
  • src/components/PurchaseSummary/type.ts

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between da04e91 and 0dc90fc.
Files selected for processing (4)
  • src/components/PurchaseSummary/PurchaseSummary.stories.tsx (1 hunks)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/type.ts (1 hunks)
  • src/components/PurchaseSummary/index.tsx (1 hunks)
  • src/components/PurchaseSummary/type.ts (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • src/components/PurchaseSummary/PurchaseSummary.stories.tsx
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/type.ts
  • src/components/PurchaseSummary/index.tsx
  • src/components/PurchaseSummary/type.ts

@joelsalmeida joelsalmeida added the publish_docs Publish Chromatic label Mar 27, 2024
@juninhokaponne juninhokaponne marked this pull request as draft March 27, 2024 13:44
@juninhokaponne juninhokaponne marked this pull request as ready for review March 27, 2024 13:46
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0dc90fc and 6617a3b.
Files selected for processing (1)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/index.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/components/PurchaseSummary/PurchaseSummaryAccordion/index.tsx

@juninhokaponne juninhokaponne merged commit 0860590 into main Apr 1, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request publish_docs Publish Chromatic
Development

Successfully merging this pull request may close these issues.

3 participants