Help finishing my widget

This is my first time contribution to the project and I am terrible with css since I work more with backend stuff. 1 . I need help understanding how to add descriptions to widget 2 . I need help trying to make my widget look good preferebly make it smaller Here is the code https://github.com/cacpmw/homarr/blob/widget/bitcoin/src/widgets/bitcoin/BitcoinWidgetTile.tsx
GitHub
homarr/src/widgets/bitcoin/BitcoinWidgetTile.tsx at widget/bitcoin ...
Customizable browser's home page to interact with your homeserver's Docker containers (e.g. Sonarr/Radarr) - cacpmw/homarr
No description
No description
Solution:
GitHub
Widget: Bitcoin by cacpmw · Pull Request #1999 · ajnart/homarr
Category Widget Overview A very simple bitcoin widget to fetch current price in USD and EUR plus the current recommended fees per transaction. It uses the free mempool api I intend to improve this ...
Jump to solution
34 Replies
Cakey Bot
Cakey Bot9mo ago
Thank you for submitting a support request. Depending on the volume of requests, our team should get in contact with you shortly.
⚠️ Please include the following details in your post or we may reject your request without further comment: - Log (See https://homarr.dev/docs/community/faq#how-do-i-open-the-console--log) - Operating system (Unraid, TrueNAS, Ubuntu, ...) - Exact Homarr version (eg. 0.15.0, not latest) - Configuration (eg. docker-compose, screenshot or similar. Use ``your-text`` to format) - Other relevant information (eg. your devices, your browser, ...)
❓ Frequently Asked Questions | Homarr documentation
Can I install Homarr on a Raspberry Pi?
Serenaphic
Serenaphic9mo ago
Hi, We like the idea of a cryptocurrency widget. Those are things that we might say once you make the PR but you might be interested to know it already: Would it be possible to have a more advanced one that does more than just Bitcoin? Is there any selfhosted app about crypto on which it could be based instead? (Since almost all our widgets are about selfhosting) For your questions: Description and name are set in the translation files. Sizing: use the h and w parameters to 100% to make sure they do not grow bigger than needed and search about flex. Personally I would put the image smaller on the left side with a price stack on the right.
Yossi
Yossi9mo ago
Hi @Carlos Carneiro I can help you if needed. I’ll try to find if there is a self-hosting app for crypto.There are some websites for that.
Carlos Carneiro
Carlos CarneiroOP9mo ago
I dont know many crypto apis. Also since I am not familiar with Homarr from a dev point of view I decided I wanted to a small contribution first. My plan is to increment this widget over time. I want to make it possible to verify transactions just by inputting an address too. I wanted to make it smaller but I terrible at styling things @Yossi if you can make my widget look good Id owe you one
Serenaphic
Serenaphic9mo ago
API's can be tricky, which is why we prefer the ones from selfhosting. If you want to make a small contribution first, there are a few "good first issue" to tackle that we leave purposely for learning. If you want to stick to that one it's fine too, but you're going to have a lot of request really fast about doing more on the widget so I'd suggest doing them from the get go. (Also people doing their own updates on it, so potentially impeding your gradual work on it) Transactions may be a big security concern that goes way out of what homarr is, but I don't know enough about it to be sure, so just saying. About the styling, since you're learning maybe you can try yourself a bit more with the clues I gave, it's a good opportunity and I think you'd be capable with the context of my previous message.
Carlos Carneiro
Carlos CarneiroOP9mo ago
All bitcoin transactions are public. When we lookup for a transaction by address we see all the public available information about that. Like when I am expecting some bitcoin i want to see how many confirmations are there for example and that is public available but i just dont wanna leave my dashboard. As of other people coming and contributing to this widget I am ok with that. But I will implement other functionalities already. I am feeling comfortable with it. As of my styling capabilities I have already tried a lot to learn how to work with css that is the one thing I can never learn.
Anyway I will try a bit more making it look beautiful and also find some selfhosted btc api but I dont think I will be successful on those ones
Serenaphic
Serenaphic9mo ago
No need for CSS here, it's pure HTML
Carlos Carneiro
Carlos CarneiroOP9mo ago
ok I will remove css and make it as simple as possible. Anyone willing to jumping and beautify it with styling is welcome About bitcoin selfhosted api, it might be possible to get information from a selfhosted bitcoin node I am not sure though
Serenaphic
Serenaphic9mo ago
Had you actually done everything about styling in a CSS file on the side? everything can be done in the HTML part, even styling can be done in there. After a bit of research, it is true that selfhosted option for market monitoring doesn't seem to be that widespread if existing at all. Then I would only ask to use the most reliable and known source if possible. I think most website have an API, you just have to explicitly search for it.
Carlos Carneiro
Carlos CarneiroOP9mo ago
This is my new style
No description
Carlos Carneiro
Carlos CarneiroOP9mo ago
As far as I know https://mempool.space is among the most used bitcoin plataforms
The Mempool Open Source Project®
Explore the full Bitcoin ecosystem with mempool.space
Carlos Carneiro
Carlos CarneiroOP9mo ago
and I just found out that they have their own node package @mempool/mempool.js
Serenaphic
Serenaphic9mo ago
Yeah but that API is limited to bitcoin isn't it? Wouldn't it be better to have a tracker for a lot of crypto coins? The only one I know of is Binance and they have an API. No idea if they are trustworthy enough.
Carlos Carneiro
Carlos CarneiroOP9mo ago
Yes mempool only supports bitcoin. It is a consensus between the cryptocurrency community that all other coins are called "shitcoins". Anyway, if anyone else would like to jumping on this one with me to add more coins is welcome. I my self only own bitcoins regarding binance is involved in a lot of scandals plus it is a chinese company which makes me frown upon them when it comes to trusting
Serenaphic
Serenaphic9mo ago
Yeah there's a lot of that in the crypto space which is why I don't really like it. I think delivering data on all coins is best as most people will have shitcoins they want to follow.
Carlos Carneiro
Carlos CarneiroOP9mo ago
Can someone help understand what is wrong with my useEffect
function BitcoinWidgetTile({ widget }: BitcoinWidgetTileProps) {
const [input, setInput] = useState('');
const [latestTransaction, setLatestTransaction] = useState<LatestAddressTransaction | undefined>(undefined);
const { data: initialData, isLoading, isError } = api.bitcoin.getInitialData.useQuery(undefined);
const { t } = useTranslation('modules/bitcoin');
useEffect(() => {
const { data: transaction } = api.bitcoin.getLatestAddressTransaction.useQuery(input);
setLatestTransaction(transaction);
console.log('useEffect');
}, [input]);
.
.
.
}
function BitcoinWidgetTile({ widget }: BitcoinWidgetTileProps) {
const [input, setInput] = useState('');
const [latestTransaction, setLatestTransaction] = useState<LatestAddressTransaction | undefined>(undefined);
const { data: initialData, isLoading, isError } = api.bitcoin.getInitialData.useQuery(undefined);
const { t } = useTranslation('modules/bitcoin');
useEffect(() => {
const { data: transaction } = api.bitcoin.getLatestAddressTransaction.useQuery(input);
setLatestTransaction(transaction);
console.log('useEffect');
}, [input]);
.
.
.
}
I am getting this error I cant seem to see the mistake:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
Serenaphic
Serenaphic9mo ago
Not sure you can make an api call inside a useEffect You don't need to save the value from the API btw, not sure what you're trying to do here
Carlos Carneiro
Carlos CarneiroOP9mo ago
I have an input field that should make api calls everytime input changes. I was avoiding to use a submit button but I guess I will have to use it
Serenaphic
Serenaphic9mo ago
Yeah, never do that Just intercept the "enter" key and a button with onclick
Carlos Carneiro
Carlos CarneiroOP9mo ago
No description
Serenaphic
Serenaphic9mo ago
Also, you can use the onChange event of the textbox for that, but again, never make calls like that. If one user types out the whole thing by hand, it's gonna make a call every keystroke. That's bad
Carlos Carneiro
Carlos CarneiroOP9mo ago
I know that. Usually users paste bitcoin addresses but the OnChange doesnt capture pasting Cant find the where should be stored the translation files Is there any code contributor docs?
Serenaphic
Serenaphic9mo ago
Like I said, doesn't matter anyway, only capture the enter key. You might need to create one for your widget public\locales\en\modules
Carlos Carneiro
Carlos CarneiroOP9mo ago
I did that but was unsure. Do I have to make it for every language out there?
Serenaphic
Serenaphic9mo ago
No no no, only english. Don't do anything other than english
Carlos Carneiro
Carlos CarneiroOP9mo ago
check this out
No description
Carlos Carneiro
Carlos CarneiroOP9mo ago
i made the bitcoin module on the en folder
Carlos Carneiro
Carlos CarneiroOP9mo ago
No description
Serenaphic
Serenaphic9mo ago
Translation doesn't play nice with hot reloading, restart the debugging
Carlos Carneiro
Carlos CarneiroOP9mo ago
working!!!
Serenaphic
Serenaphic9mo ago
That's great :) Remember, any string that a user can see must be translatable, so use that file extensively
Carlos Carneiro
Carlos CarneiroOP9mo ago
okay Okay, so I finished. I removed the option to input address for now cuz I couldnt get a nice solution. Hopefully I will improve it with more features.
Solution
Carlos Carneiro
Carlos Carneiro9mo ago
GitHub
Widget: Bitcoin by cacpmw · Pull Request #1999 · ajnart/homarr
Category Widget Overview A very simple bitcoin widget to fetch current price in USD and EUR plus the current recommended fees per transaction. It uses the free mempool api I intend to improve this ...
Want results from more Discord servers?
Add your server