Created
July 13, 2021 16:05
-
-
Save haydenbbickerton/21ed306de8bfded6d09b0e1a5709cb99 to your computer and use it in GitHub Desktop.
Legacy Styles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="ur-legacy-styles"> | |
<slot></slot> | |
</div> | |
</template> | |
<script> | |
export default { | |
name: 'ur-legacy-styles', | |
}; | |
</script> | |
<style scoped lang="scss"> | |
.ur-legacy-styles /deep/ { | |
@import "./legacy-styles.scss"; | |
} | |
</style> |
If paired with a custom element solution like vuidget, you could conceivably have something like:
<body>
<bootstrap-3-styles>
<div class="container">
...
</div>
</bootstrap-3-styles>
<bootstrap-4-styles>
<div class="grid">
...
</div>
</bootstrap-4-styles>
<zurb-foundation-styles>
<button class="button">
...
</div>
</zurb-foundation-styles>
</body>
with a single, async and lazy loadable script tag per style-set, making them compatible with all browsers/platforms back to IE8.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The beauty of the legacy styles component is that it will prefix every single rule imported from the legacy css file. So whether you want to pass a large section of a page (like a
<div class="header"
) or just a simple<button>
, it will be styled using the old website CSS. And that goes down to any depth and any selectors that get imported.I've actually not seen this approach used anywhere else, which made me somewhat hesitant at first but it has worked swimmingly well even for components like modal backdrops and portal components, and has stood up very well across the large amount of traffic and different sites used under the United rentals umbrella.