scrollbarStyle.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2024 LangChat. TyCoding All Rights Reserved.
  3. *
  4. * Licensed under the GNU Affero General Public License, Version 3 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * https://www.gnu.org/licenses/agpl-3.0.html
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import { darkTheme, lightTheme } from 'naive-ui';
  17. const setupScrollbarStyle = () => {
  18. const style = document.createElement('style');
  19. const styleContent = `
  20. ::-webkit-scrollbar {
  21. background-color: transparent;
  22. width: ${lightTheme.Scrollbar.common?.scrollbarWidth};
  23. }
  24. ::-webkit-scrollbar-thumb {
  25. background-color: ${lightTheme.Scrollbar.common?.scrollbarColor};
  26. border-radius: ${lightTheme.Scrollbar.common?.scrollbarBorderRadius};
  27. }
  28. html.dark ::-webkit-scrollbar {
  29. background-color: transparent;
  30. width: ${darkTheme.Scrollbar.common?.scrollbarWidth};
  31. }
  32. html.dark ::-webkit-scrollbar-thumb {
  33. background-color: ${darkTheme.Scrollbar.common?.scrollbarColor};
  34. border-radius: ${darkTheme.Scrollbar.common?.scrollbarBorderRadius};
  35. }
  36. `;
  37. style.innerHTML = styleContent;
  38. document.head.appendChild(style);
  39. };
  40. export default setupScrollbarStyle;