Skip to content

🖍 [bento][amp-sidebar] Allow various CSS properties to be configurable on amp-sidebar#31628

Merged
krdwan merged 9 commits intoampproject:masterfrom
krdwan:amp-sidebar-colors
Jan 11, 2021
Merged

🖍 [bento][amp-sidebar] Allow various CSS properties to be configurable on amp-sidebar#31628
krdwan merged 9 commits intoampproject:masterfrom
krdwan:amp-sidebar-colors

Conversation

@krdwan
Copy link
Copy Markdown
Contributor

@krdwan krdwan commented Dec 16, 2020

1/15

  • Added updates to tests

Overview of PR:

  1. Have included multiple configurable CSS properties for sidebar listed below:
  • color
  • background-color
  • height
  • --story-page-vh
  • top
  • max-height
  • max-width
  • min-width
  • outline
  • z-index
  • width
  • padding
  • border
  1. In amp mode these can be directly controlled by user supplied CSS
         amp-sidebar {
              color: ${foregroundColor};
              background-color: ${backgroundColor};
          }
          amp-sidebar::part(backdrop) {
              background-color: ${maskBackgroundColor};
          }
  1. In preact mode pass in a style object as the style and backdropStyle props. To have the style included inline in the rendered element.
      <Sidebar 
        style={{color: foregroundColor, backgroundColor: someColor}}
        backdropStyle={{backgroundColor: someColor}}
      />

12/18

  • Added additional styles that user can configure
  • Updated amp storybook

To do:

  1. Update Preact storybook
  2. Add tests

Add feature to customize colors in amp-sidebar

  1. sidebar color - customize the color of text in the sidebar
  2. sidebar background - customize the color of the background in the sidebar
  3. mask color - customize the mask color

To change these in amp mode include the following css:

         amp-sidebar {
              color: ${foregroundColor};
              background-color: ${backgroundColor};
          }
          amp-sidebar::part(mask) {
              background-color: ${maskBackgroundColor};
          }

To change these in preact mode include the following props:

      <Sidebar 
        style={{color: foregroundColor, backgroundColor: someColor}}
        maskStyle={{backgroundColor: someColor}}
      />

Open Questions:

  1. Should we make the customizing the mask and sidebar symmetric in amp mode? (same syntax) (i.e. to change sidebar color use a CSS selector like amp-sidebar::part(sidebar))

Answer: no, the current is an existing pattern, see: https://jsbin.com/nawecap/edit?html,css,output

@krdwan krdwan requested a review from dvoytenko December 16, 2020 15:42
height: '100vh',
top: 0,
maxHeight: '100vh',
maxWidth: '80vw',
Copy link
Copy Markdown
Contributor Author

@krdwan krdwan Dec 18, 2020

Choose a reason for hiding this comment

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

Removed !important from maxHeight, maxWidth, minWidth here. This allows user to overwrite by specifying amp-sidebar { selector (which is lower specificity than class selector). (for amp mode)

Opinons?

@krdwan krdwan requested a review from dvoytenko December 18, 2020 16:42
@krdwan krdwan changed the title 🖍 [bento][amp-sidebar] Customizable colors for sidebar 🖍 [bento][amp-sidebar] Allow various CSS properties to be configurable on amp-sidebar Jan 5, 2021
@krdwan krdwan requested a review from caroqliu January 5, 2021 20:11
@krdwan krdwan requested a review from dvoytenko January 11, 2021 17:48
@amp-bundle-size amp-bundle-size bot requested a review from alanorozco January 11, 2021 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants