Giter Site home page Giter Site logo

Table style customizations about attractions HOT 5 CLOSED

techpet avatar techpet commented on June 26, 2024
Table style customizations

from attractions.

Comments (5)

illright avatar illright commented on June 26, 2024

Due to the way Svelte scopes its styles, you have to specifically opt out of scoping for your styles to reach the components of Attractions. Try the following:

<style lang="scss">
-.my-table {
+.my-table :global {
	td {
		border:none;
	}
}
</style>

<Table class="my-table" ... />

from attractions.

techpet avatar techpet commented on June 26, 2024

Unfortunately that doesn't work either in my component...

Full code here:

<script lang="ts">
	import {Table} from 'attractions';


	const headers = [
    { text: 'First Name', value: 'firstName' },
    { text: 'Last Name', value: 'lastName' },
    { text: 'Age', value: 'age', align: 'end' },
  ];
  const items = [
    { firstName: 'John', lastName: 'Doe', age: 694 },
    { firstName: 'Leo', lastName: 'Tolstoy', age: new Date().getFullYear() - 1828 },
    { firstName: 'فلان', lastName: 'الفلاني', age: 42 },
    { firstName: 'Иван', lastName: 'Иванов', age: 69 },
  ];

</script>

<style lang="scss">
		.my-table :global {
				td {
					border:none;
				}
				
		}
		

</style>

<Table {headers} {items} alternatingRows={false} class="my-table" />

and the result:
image

from attractions.

techpet avatar techpet commented on June 26, 2024

If I place the style code inside the global.scss instead of inline into my component it works though. Any ideas?

from attractions.

illright avatar illright commented on June 26, 2024

Oh, wait, sorry, I misled you there a bit. The :global modifier should be placed before .my-table, not after. However, to preserve scoping, you would need to add some scoped selector in the beginning, for example:

<script lang="ts">
  import { Table } from 'attractions';

  const headers = [
    { text: 'First Name', value: 'firstName' },
    { text: 'Last Name', value: 'lastName' },
    { text: 'Age', value: 'age', align: 'end' },
  ];
  const items = [
    { firstName: 'John', lastName: 'Doe', age: 694 },
    { firstName: 'Leo', lastName: 'Tolstoy', age: new Date().getFullYear() - 1828 },
    { firstName: 'فلان', lastName: 'الفلاني', age: 42 },
    { firstName: 'Иван', lastName: 'Иванов', age: 69 },
  ];

</script>

<style lang="scss">
  .something-local :global .my-table {
    td {
      border: none !important;
    }
  }
</style>

<div class="something-local">
  <Table {headers} {items} alternatingRows={false} class="my-table" />
</div>

Note the usage of !important. That's another problem to overcome – specificity. If you have a more specific selector, you can avoid !important, but if not, that should stay.

from attractions.

techpet avatar techpet commented on June 26, 2024

Perfect! It works this way, thank you very much!

from attractions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.