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

Created custom css style upload #485

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

milospp
Copy link
Contributor

@milospp milospp commented Jan 16, 2025

VIVO GitHub issue:
Linked Vitro PR:

What does this pull request do?

This pull request enables administrators to manage custom CSS styles directly from the Site Admin page. Admins can upload, download, and remove custom CSS styles, as well as reset styles to ensure accessibility and functionality remain intact.

What's new?

  1. Added a new page for managing custom CSS styles under Site Admin > Site Information.
  2. Features include:
    • Upload custom CSS files to override existing styles.
    • Download current custom CSS.
    • Remove custom CSS to revert to the default styles.
  3. Added download links for CSS files used in the current theme.
  4. Created a Reset button that remains visible and functional, even when styles are broken due to invalid or problematic CSS.

Screenshoots

Style edit page

image image

Example css

body {
    background: #333;
}
image

Broken contrast css (RESET button is still visible)

image

How should this be tested?

Test for every theme

Uploading regular CSS

  1. Login as an admin.
  2. Navigate to Site Admin > Site Information > Change CSS Styles.
  3. Test downloading the default styles.
  4. Upload a custom CSS file with the following content
body {
    background: red;
}
  1. Clikc upload
    Expected Result: The site background should change to red.

Download Custom CSS

  1. After uploading custom CSS, return to the Change CSS Styles page.
  2. Click Download Custom CSS.
    Expected Result: The downloaded file should match the uploaded custom CSS.

Removing Custom CSS

After uploading custom CSS, navigate to the Change CSS Styles page.
Click Remove Custom CSS.
Expected Result: The site should revert to the default styles.

Uploading broken CSS

  1. Test with CSS that introduces accessibility or visibility issues, such as
    Example:
* {
    background: white !important;
    color: white !important;
    border-color: transparent !important;
}

or

* {
    background: white !important;
    color: white !important;
    border-color: transparent !important;
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}
  1. Upload the CSS file and observe the Reset button.
    Reset button should still be visible and working
  2. Click Reset

Additional Notes:

The custom CSS file is saved using the Vitro FileStorage class and file is stored into vivo-home/uploads.
The file's path is stored in the ApplicationBean under the key customCssPath (vitro-kb-applicationMetadata).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant