Skip to content

[TreeView] Migrate TreeItem to emotion#25835

Merged
mnajdova merged 12 commits into
mui:nextfrom
siriwatknp:tree-item-emotion
Apr 27, 2021
Merged

[TreeView] Migrate TreeItem to emotion#25835
mnajdova merged 12 commits into
mui:nextfrom
siriwatknp:tree-item-emotion

Conversation

@siriwatknp

@siriwatknp siriwatknp commented Apr 19, 2021

Copy link
Copy Markdown
Member

One chunk of #24405

Comment thread packages/material-ui-lab/src/TreeItem/TreeItem.d.ts
@mui-pr-bot

mui-pr-bot commented Apr 19, 2021

Copy link
Copy Markdown

Details of bundle changes

@material-ui/lab: parsed: +0.25% , gzip: +0.16%

Generated by 🚫 dangerJS against a3234ed

Comment thread test/utils/describeConformanceV5.js Outdated
@siriwatknp siriwatknp added the scope: tree view Changes related to the tree view. This includes TreeView, TreeItem. label Apr 19, 2021
@siriwatknp
siriwatknp requested a review from mnajdova April 21, 2021 16:44

@mnajdova mnajdova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a bit trickier. The only problem I see is with the styles for the iconContainer and the label, but it is solvable. Let me know if you need some more help.

Comment thread docs/src/pages/components/tree-view/IconExpansionTreeView.tsx Outdated
Comment thread packages/material-ui-lab/src/TreeItem/TreeItem.js Outdated
Comment thread packages/material-ui-lab/src/TreeItem/TreeItem.js Outdated
Comment thread packages/material-ui-lab/src/TreeItem/TreeItem.js Outdated
Comment thread packages/material-ui-lab/src/TreeItem/TreeItem.js Outdated
Comment thread packages/material-ui-lab/src/TreeItem/TreeItem.js Outdated
Comment thread packages/material-ui-lab/src/TreeItem/TreeItemContent.js Outdated
@siriwatknp
siriwatknp requested a review from mnajdova April 23, 2021 16:34
Comment thread docs/src/pages/components/tree-view/GmailTreeView.js
Comment thread packages/material-ui-lab/src/TreeItem/TreeItem.test.js Outdated
Comment thread packages/material-ui-lab/src/TreeItem/index.d.ts
Comment thread packages/material-ui-lab/src/TreeItem/TreeItem.js Outdated
Comment thread packages/material-ui-lab/src/TreeItem/TreeItem.js Outdated
Comment thread packages/material-ui-lab/src/TreeItem/TreeItemContent.js Outdated
Comment thread docs/src/pages/components/tree-view/GmailTreeView.tsx
@siriwatknp

siriwatknp commented Apr 25, 2021

Copy link
Copy Markdown
Member Author

@oliviertassinari one question about theme styleOverrides for pseudo class. Is this the correct way to do in theme?

createMuiTheme({
  components: {
    MuiTreeItem: {
      styleOverrides: {
        root: {
          '& .Mui-focused': {
            ...styles
          },
          '& .Mui-expanded': {
            ...styles
          }
        }
      }
    }
  }
})

@oliviertassinari

Copy link
Copy Markdown
Member

@siriwatknp Yes

@mnajdova

Copy link
Copy Markdown
Member

@oliviertassinari one question about theme styleOverrides for pseudo class. Is this the correct way to do in theme?

createMuiTheme({
  components: {
    MuiTreeItem: {
      styleOverrides: {
        root: {
          '& .Mui-focused': {
            ...styles
          },
          '& .Mui-expanded': {
            ...styles
          }
        }
      }
    }
  }
})

@siriwatknp just watch out for the spacings, I believe it should be:

createMuiTheme({
  components: {
    MuiTreeItem: {
      styleOverrides: {
        root: {
-         '& .Mui-focused': {
+         '&.Mui-focused': {
            ...styles
          },
-         '& .Mui-expanded': {
+         '&.Mui-expanded': {
            ...styles
          }
        }
      }
    }
  }
})

backgroundColor: `var(--tree-view-bg-color, ${theme.palette.action.selected})`,
color: 'var(--tree-view-color)',
},
'& $label': {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we use the global class here? For example:

Suggested change
'& $label': {
'& .MuiTreeItem-label': {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or even better:

Suggested change
'& $label': {
'& .${treeItemClasses.label}': {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mnajdova similar to @oliviertassinari suggestion, but there are many places still using $ in this file so I think it might be better to update the whole demo in another PR. is that okay?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok, got it, sorry missed previous question I guess :)

@siriwatknp

siriwatknp commented Apr 26, 2021

Copy link
Copy Markdown
Member Author

@oliviertassinari one question about theme styleOverrides for pseudo class. Is this the correct way to do in theme?

createMuiTheme({
  components: {
    MuiTreeItem: {
      styleOverrides: {
        root: {
          '& .Mui-focused': {
            ...styles
          },
          '& .Mui-expanded': {
            ...styles
          }
        }
      }
    }
  }
})

@siriwatknp just watch out for the spacings, I believe it should be:

createMuiTheme({
  components: {
    MuiTreeItem: {
      styleOverrides: {
        root: {
-         '& .Mui-focused': {
+         '&.Mui-focused': {
            ...styles
          },
-         '& .Mui-expanded': {
+         '&.Mui-expanded': {
            ...styles
          }
        }
      }
    }
  }
})

Got your point, do I need to change? because right now the pseudo styles is at Content, not Root.

const StyledTreeItemContent = experimentalStyled(...)({
  [`&.${treeItemClasses.disabled}`]: {
    ...
  },
  [`&.${treeItemClasses.focused}`]: {
    ...
  },
  [`&.${treeItemClasses.selected}`]: {
    ...
  },
})

@mnajdova

Copy link
Copy Markdown
Member

Got your point, do I need to change? because right now the pseudo styles is at Content, not Root.

I would expect in that case maybe either :

createMuiTheme({
  components: {
    MuiTreeItem: {
      styleOverrides: {
        content: { // target content
          '&.Mui-focused': {
            ...styles
          },
           '&.Mui-expanded': {
            ...styles
          }
        }
      }
    }
  }
})

or this

createMuiTheme({
  components: {
    MuiTreeItem: {
      styleOverrides: {
        root: {
          '& .MuiTreeItem-content.Mui-focused': {
            ...styles
          },
           '& .MuiTreeItem-content.Mui-expanded': {
            ...styles
          }
        }
      }
    }
  }
})

@siriwatknp

Copy link
Copy Markdown
Member Author

Got your point, do I need to change? because right now the pseudo styles is at Content, not Root.

I would expect in that case maybe either :

createMuiTheme({
  components: {
    MuiTreeItem: {
      styleOverrides: {
        content: { // target content
          '&.Mui-focused': {
            ...styles
          },
           '&.Mui-expanded': {
            ...styles
          }
        }
      }
    }
  }
})

or this

createMuiTheme({
  components: {
    MuiTreeItem: {
      styleOverrides: {
        root: {
          '& .MuiTreeItem-content.Mui-focused': {
            ...styles
          },
           '& .MuiTreeItem-content.Mui-expanded': {
            ...styles
          }
        }
      }
    }
  }
})

Yep, I am good with this.

@mnajdova mnajdova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: tree view Changes related to the tree view. This includes TreeView, TreeItem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants