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

Using padding object in table cell #53

Open
d3v1an7 opened this issue Jun 4, 2024 · 1 comment
Open

Using padding object in table cell #53

d3v1an7 opened this issue Jun 4, 2024 · 1 comment

Comments

@d3v1an7
Copy link

d3v1an7 commented Jun 4, 2024

Hey! First off, thanks heaps for this, super helpful :)
I'm using this in a non-standard way, vanilla JS + JSdoc/checkJs -- feel free to close if that is the cause.

Code example:

/**
 * @param {object} params
 * @param {string} params.text
 * @returns {import('apple-news-format').AppleNews.HTMLTable} Valid HTMLTable object.
 */
function generateKicker({ text }) {
  return {
    role: "htmltable",
    html: `<table><tr><td>Foo</td><td>${text}</td></tr></table>`,
    style: {
      tableStyle: {
        cells: {
          textStyle: {
            textTransform: "uppercase",
          },
          conditional: [
            {
              selectors: [{ descriptor: null, evenColumns: true }],
              backgroundColor: "#E9FF5C",
              padding: {
                left: 6,
                right: 4,
                bottom: 2,
                top: 2,
              },
            },
            {
              selectors: [{ descriptor: null, oddColumns: true }],
              width: 1,
              padding: {
                left: 12,
              },
            },
          ],
        },
      },
    },
  };
}

I'm getting the following error on padding:

Type '{ left: number; right: number; bottom: number; top: number; }' is not assignable to type 'string | number'.ts(2322)
table-cell-style-base.d.ts(10, 5): The expected type comes from property 'padding' which is declared here on type 'ConditionalTableCellStyle'

Screenshot 2024-06-04 at 1 07 34 PM

I believe the padding object should be supported, as per: https://developer.apple.com/documentation/apple_news/padding

@Robert-Fairley
Copy link
Owner

Hi Ben, I wrote a response already but I was mistaken. It looks like the type needs a quick update. I'll notify you again here when there's a new patch published

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

No branches or pull requests

2 participants